mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-02-28 21:23:01 +00:00
Compare commits
3 commits
63d7e60b5a
...
feed212682
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
feed212682 | ||
|
|
ea0da32e81 | ||
|
|
2e01ff19f7 |
3 changed files with 53 additions and 7 deletions
|
|
@ -554,7 +554,7 @@ class TlsStreamSettings extends XrayCommonClass {
|
|||
maxVersion = TLS_VERSION_OPTION.TLS13,
|
||||
cipherSuites = '',
|
||||
rejectUnknownSni = false,
|
||||
verifyPeerCertInNames = ['dns.google', 'cloudflare-dns.com'],
|
||||
verifyPeerCertByName = ['dns.google', 'cloudflare-dns.com'],
|
||||
disableSystemRoot = false,
|
||||
enableSessionResumption = false,
|
||||
certificates = [new TlsStreamSettings.Cert()],
|
||||
|
|
@ -569,7 +569,7 @@ class TlsStreamSettings extends XrayCommonClass {
|
|||
this.maxVersion = maxVersion;
|
||||
this.cipherSuites = cipherSuites;
|
||||
this.rejectUnknownSni = rejectUnknownSni;
|
||||
this.verifyPeerCertInNames = Array.isArray(verifyPeerCertInNames) ? verifyPeerCertInNames.join(",") : verifyPeerCertInNames;
|
||||
this.verifyPeerCertByName = Array.isArray(verifyPeerCertByName) ? verifyPeerCertByName.join(",") : verifyPeerCertByName;
|
||||
this.disableSystemRoot = disableSystemRoot;
|
||||
this.enableSessionResumption = enableSessionResumption;
|
||||
this.certs = certificates;
|
||||
|
|
@ -603,7 +603,7 @@ class TlsStreamSettings extends XrayCommonClass {
|
|||
json.maxVersion,
|
||||
json.cipherSuites,
|
||||
json.rejectUnknownSni,
|
||||
json.verifyPeerCertInNames,
|
||||
json.verifyPeerCertByName,
|
||||
json.disableSystemRoot,
|
||||
json.enableSessionResumption,
|
||||
certs,
|
||||
|
|
@ -621,7 +621,7 @@ class TlsStreamSettings extends XrayCommonClass {
|
|||
maxVersion: this.maxVersion,
|
||||
cipherSuites: this.cipherSuites,
|
||||
rejectUnknownSni: this.rejectUnknownSni,
|
||||
verifyPeerCertInNames: this.verifyPeerCertInNames.split(","),
|
||||
verifyPeerCertByName: this.verifyPeerCertByName.split(","),
|
||||
disableSystemRoot: this.disableSystemRoot,
|
||||
enableSessionResumption: this.enableSessionResumption,
|
||||
certificates: TlsStreamSettings.toJsonArray(this.certs),
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@
|
|||
<a-form-item label="Session Resumption">
|
||||
<a-switch v-model="inbound.stream.tls.enableSessionResumption"></a-switch>
|
||||
</a-form-item>
|
||||
<a-form-item label="VerifyPeerCertInNames">
|
||||
<a-input v-model.trim="inbound.stream.tls.verifyPeerCertInNames"></a-input>
|
||||
<a-form-item label="verifyPeerCertByName">
|
||||
<a-input v-model.trim="inbound.stream.tls.verifyPeerCertByName"></a-input>
|
||||
</a-form-item>
|
||||
<a-divider :style="{ margin: '3px 0' }"></a-divider>
|
||||
<template v-for="cert,index in inbound.stream.tls.certs">
|
||||
|
|
|
|||
|
|
@ -1088,12 +1088,57 @@ func (s *ServerService) UpdateGeofile(fileName string) error {
|
|||
}
|
||||
}
|
||||
downloadFile := func(url, destPath string) error {
|
||||
resp, err := http.Get(url)
|
||||
var req *http.Request
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return common.NewErrorf("Failed to create HTTP request for %s: %v", url, err)
|
||||
}
|
||||
var localFileModTime time.Time
|
||||
if fileInfo, err := os.Stat(destPath); err == nil {
|
||||
localFileModTime = fileInfo.ModTime()
|
||||
if !localFileModTime.IsZero() {
|
||||
req.Header.Set("If-Modified-Since", localFileModTime.UTC().Format(http.TimeFormat))
|
||||
}
|
||||
}
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return common.NewErrorf("Failed to download Geofile from %s: %v", url, err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
// Parse Last-Modified header from server
|
||||
var serverModTime time.Time
|
||||
serverModTimeStr := resp.Header.Get("Last-Modified")
|
||||
if serverModTimeStr != "" {
|
||||
parsedTime, err := time.Parse(http.TimeFormat, serverModTimeStr)
|
||||
if err != nil {
|
||||
logger.Warningf("Failed to parse Last-Modified header for %s: %v", url, err)
|
||||
} else {
|
||||
serverModTime = parsedTime
|
||||
}
|
||||
}
|
||||
|
||||
// Function to update local file's modification time
|
||||
updateFileModTime := func() {
|
||||
if !serverModTime.IsZero() {
|
||||
if err := os.Chtimes(destPath, serverModTime, serverModTime); err != nil {
|
||||
logger.Warningf("Failed to update modification time for %s: %v", destPath, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle 304 Not Modified
|
||||
if resp.StatusCode == http.StatusNotModified {
|
||||
updateFileModTime()
|
||||
return nil
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return common.NewErrorf("Failed to download Geofile from %s: received status code %d", url, resp.StatusCode)
|
||||
}
|
||||
|
||||
file, err := os.Create(destPath)
|
||||
if err != nil {
|
||||
return common.NewErrorf("Failed to create Geofile %s: %v", destPath, err)
|
||||
|
|
@ -1105,6 +1150,7 @@ func (s *ServerService) UpdateGeofile(fileName string) error {
|
|||
return common.NewErrorf("Failed to save Geofile %s: %v", destPath, err)
|
||||
}
|
||||
|
||||
updateFileModTime()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue