Skip to content

Commit 4577fb1

Browse files
authored
Merge pull request #368 from tobychui/v3.1.2
v3.1.2
2 parents 95d0a98 + f877bf9 commit 4577fb1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+180053
-35096
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ If you have no background in setting up reverse proxy or web routing, you should
5151

5252
## Build from Source
5353

54-
Requires Go 1.22 or higher
54+
Requires Go 1.23 or higher
5555

5656
```bash
5757
git clone https://github.com/tobychui/zoraxy

src/acme.go

+23-8
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,20 @@ func acmeRegisterSpecialRoutingRule() {
8585
// This function check if the renew setup is satisfied. If not, toggle them automatically
8686
func AcmeCheckAndHandleRenewCertificate(w http.ResponseWriter, r *http.Request) {
8787
isForceHttpsRedirectEnabledOriginally := false
88+
requireRestorePort80 := false
8889
dnsPara, _ := utils.PostBool(r, "dns")
8990
if !dnsPara {
91+
9092
if dynamicProxyRouter.Option.Port == 443 {
93+
//Check if port 80 is enabled
94+
if !dynamicProxyRouter.Option.ListenOnPort80 {
95+
//Enable port 80 temporarily
96+
SystemWideLogger.PrintAndLog("ACME", "Temporarily enabling port 80 listener to handle ACME request ", nil)
97+
dynamicProxyRouter.UpdatePort80ListenerState(true)
98+
requireRestorePort80 = true
99+
time.Sleep(2 * time.Second)
100+
}
101+
91102
//Enable port 80 to 443 redirect
92103
if !dynamicProxyRouter.Option.ForceHttpsRedirect {
93104
SystemWideLogger.Println("Temporary enabling HTTP to HTTPS redirect for ACME certificate renew requests")
@@ -107,8 +118,8 @@ func AcmeCheckAndHandleRenewCertificate(w http.ResponseWriter, r *http.Request)
107118
}
108119
}
109120

110-
//Add a 3 second delay to make sure everything is settle down
111-
time.Sleep(3 * time.Second)
121+
//Add a 2 second delay to make sure everything is settle down
122+
time.Sleep(2 * time.Second)
112123

113124
// Pass over to the acmeHandler to deal with the communication
114125
acmeHandler.HandleRenewCertificate(w, r)
@@ -117,13 +128,17 @@ func AcmeCheckAndHandleRenewCertificate(w http.ResponseWriter, r *http.Request)
117128
tlsCertManager.UpdateLoadedCertList()
118129

119130
//Restore original settings
120-
if dynamicProxyRouter.Option.Port == 443 && !dnsPara {
121-
if !isForceHttpsRedirectEnabledOriginally {
122-
//Default is off. Turn the redirection off
123-
SystemWideLogger.PrintAndLog("ACME", "Restoring HTTP to HTTPS redirect settings", nil)
124-
dynamicProxyRouter.UpdateHttpToHttpsRedirectSetting(false)
125-
}
131+
if requireRestorePort80 {
132+
//Restore port 80 listener
133+
SystemWideLogger.PrintAndLog("ACME", "Restoring previous port 80 listener settings", nil)
134+
dynamicProxyRouter.UpdatePort80ListenerState(false)
135+
}
136+
if !isForceHttpsRedirectEnabledOriginally {
137+
//Default is off. Turn the redirection off
138+
SystemWideLogger.PrintAndLog("ACME", "Restoring HTTP to HTTPS redirect settings", nil)
139+
dynamicProxyRouter.UpdateHttpToHttpsRedirectSetting(false)
126140
}
141+
127142
}
128143

129144
// HandleACMEPreferredCA return the user preferred / default CA for new subdomain auto creation

src/api.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"imuslab.com/zoraxy/mod/acme/acmedns"
99
"imuslab.com/zoraxy/mod/acme/acmewizard"
1010
"imuslab.com/zoraxy/mod/auth"
11+
"imuslab.com/zoraxy/mod/ipscan"
1112
"imuslab.com/zoraxy/mod/netstat"
1213
"imuslab.com/zoraxy/mod/netutils"
1314
"imuslab.com/zoraxy/mod/utils"
@@ -95,6 +96,21 @@ func initAPIs(targetMux *http.ServeMux) {
9596
authRouter.HandleFunc("/api/cert/checkDefault", handleDefaultCertCheck)
9697
authRouter.HandleFunc("/api/cert/delete", handleCertRemove)
9798

99+
//SSO and Oauth
100+
authRouter.HandleFunc("/api/sso/status", ssoHandler.HandleSSOStatus)
101+
authRouter.HandleFunc("/api/sso/enable", ssoHandler.HandleSSOEnable)
102+
authRouter.HandleFunc("/api/sso/setPort", ssoHandler.HandlePortChange)
103+
authRouter.HandleFunc("/api/sso/setAuthURL", ssoHandler.HandleSetAuthURL)
104+
105+
authRouter.HandleFunc("/api/sso/app/register", ssoHandler.HandleRegisterApp)
106+
//authRouter.HandleFunc("/api/sso/app/list", ssoHandler.HandleListApp)
107+
//authRouter.HandleFunc("/api/sso/app/remove", ssoHandler.HandleRemoveApp)
108+
109+
authRouter.HandleFunc("/api/sso/user/list", ssoHandler.HandleListUser)
110+
authRouter.HandleFunc("/api/sso/user/add", ssoHandler.HandleAddUser)
111+
authRouter.HandleFunc("/api/sso/user/edit", ssoHandler.HandleEditUser)
112+
authRouter.HandleFunc("/api/sso/user/remove", ssoHandler.HandleRemoveUser)
113+
98114
//Redirection config
99115
authRouter.HandleFunc("/api/redirect/list", handleListRedirectionRules)
100116
authRouter.HandleFunc("/api/redirect/add", handleAddRedirectionRule)
@@ -172,7 +188,8 @@ func initAPIs(targetMux *http.ServeMux) {
172188
authRouter.HandleFunc("/api/analytic/resetRange", AnalyticLoader.HandleRangeReset)
173189

174190
//Network utilities
175-
authRouter.HandleFunc("/api/tools/ipscan", HandleIpScan)
191+
authRouter.HandleFunc("/api/tools/ipscan", ipscan.HandleIpScan)
192+
authRouter.HandleFunc("/api/tools/portscan", ipscan.HandleScanPort)
176193
authRouter.HandleFunc("/api/tools/traceroute", netutils.HandleTraceRoute)
177194
authRouter.HandleFunc("/api/tools/ping", netutils.HandlePing)
178195
authRouter.HandleFunc("/api/tools/whois", netutils.HandleWhois)

0 commit comments

Comments
 (0)