feat: update build workflow, enhance README, and modify license for version 1.4-01
Build and Release / release (push) Successful in 1m36s
Build and Release / release (push) Successful in 1m36s
This commit is contained in:
@@ -2,11 +2,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -32,8 +34,17 @@ func rawQueryFromRequestURI(requestURI string) string {
|
|||||||
return rawQuery
|
return rawQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseRedirect(r string) (scheme, host string) {
|
||||||
|
if strings.Contains(r, "://") {
|
||||||
|
if u, err := url.Parse(r); err == nil && u.Host != "" {
|
||||||
|
return u.Scheme, u.Host
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "http", r
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
redirectHost := flag.String("r", "127.0.0.1:21000", "redirect target host")
|
redirectHost := flag.String("r", "127.0.0.1:21000", "redirect target (host:port or full URL)")
|
||||||
blockedStr := flag.String("b", "", "comma separated list of blocked ports")
|
blockedStr := flag.String("b", "", "comma separated list of blocked ports")
|
||||||
proxyPort := flag.Int("p", 0, "proxy listen port (default: auto)")
|
proxyPort := flag.Int("p", 0, "proxy listen port (default: auto)")
|
||||||
exePath := flag.String("e", "", "path to the executable")
|
exePath := flag.String("e", "", "path to the executable")
|
||||||
@@ -41,6 +52,8 @@ func main() {
|
|||||||
noSys := flag.Bool("no-sys", false, "skip certificate installation and system proxy setup")
|
noSys := flag.Bool("no-sys", false, "skip certificate installation and system proxy setup")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
redirectScheme, redirectTarget := parseRedirect(*redirectHost)
|
||||||
|
|
||||||
if !*noSys {
|
if !*noSys {
|
||||||
relaunched, err := relaunchWithAdminIfNeeded()
|
relaunched, err := relaunchWithAdminIfNeeded()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -119,6 +132,7 @@ func main() {
|
|||||||
MaxIdleConnsPerHost: 100,
|
MaxIdleConnsPerHost: 100,
|
||||||
IdleConnTimeout: 90 * time.Second,
|
IdleConnTimeout: 90 * time.Second,
|
||||||
DisableCompression: false,
|
DisableCompression: false,
|
||||||
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
}
|
}
|
||||||
proxy.CertStore = NewCertStorage()
|
proxy.CertStore = NewCertStorage()
|
||||||
proxy.OnRequest().HandleConnect(customAlwaysMitm)
|
proxy.OnRequest().HandleConnect(customAlwaysMitm)
|
||||||
@@ -171,8 +185,9 @@ func main() {
|
|||||||
Str("raw_query", rawQuery).
|
Str("raw_query", rawQuery).
|
||||||
Msg("Force redirect")
|
Msg("Force redirect")
|
||||||
|
|
||||||
req.URL.Scheme = "http"
|
req.URL.Scheme = redirectScheme
|
||||||
req.URL.Host = *redirectHost
|
req.URL.Host = redirectTarget
|
||||||
|
req.Host = redirectTarget
|
||||||
req.URL.RawQuery = rawQuery
|
req.URL.RawQuery = rawQuery
|
||||||
req.RequestURI = ""
|
req.RequestURI = ""
|
||||||
zlog.Info().Str("to_url", req.URL.String()).Msg("Force redirected")
|
zlog.Info().Str("to_url", req.URL.String()).Msg("Force redirected")
|
||||||
@@ -184,8 +199,9 @@ func main() {
|
|||||||
Str("from_url", full).
|
Str("from_url", full).
|
||||||
Str("raw_query", rawQuery).
|
Str("raw_query", rawQuery).
|
||||||
Msg("Redirect domain")
|
Msg("Redirect domain")
|
||||||
req.URL.Scheme = "http"
|
req.URL.Scheme = redirectScheme
|
||||||
req.URL.Host = *redirectHost
|
req.URL.Host = redirectTarget
|
||||||
|
req.Host = redirectTarget
|
||||||
req.URL.RawQuery = rawQuery
|
req.URL.RawQuery = rawQuery
|
||||||
req.RequestURI = ""
|
req.RequestURI = ""
|
||||||
zlog.Info().Str("to_url", req.URL.String()).Msg("Redirected domain")
|
zlog.Info().Str("to_url", req.URL.String()).Msg("Redirected domain")
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"tag": "1.3-03",
|
"tag": "1.4-01",
|
||||||
"title": "PreBuild Version 1.3 - 03"
|
"title": "PreBuild Version 1.4 - 01"
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user