Skip to content

Commit

Permalink
feat: add cookie jar option
Browse files Browse the repository at this point in the history
  • Loading branch information
zema1 committed Nov 20, 2023
1 parent 696f680 commit b4fc205
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 118 deletions.
2 changes: 2 additions & 0 deletions ctrl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Suo5Config struct {
RawHeader []string `json:"raw_header"`
DisableHeartbeat bool `json:"disable_heartbeat"`
DisableGzip bool `json:"disable_gzip"`
DisableCookiejar bool `json:"disable_cookiejar"`
TestExit string `json:"-"`

Offset int `json:"-"`
Expand Down Expand Up @@ -94,5 +95,6 @@ func DefaultSuo5Config() *Suo5Config {
RedirectURL: "",
RawHeader: []string{"User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.1.2.3"},
DisableHeartbeat: false,
DisableCookiejar: false,
}
}
9 changes: 9 additions & 0 deletions ctrl/ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"math/rand"
"net"
"net/http"
"net/http/cookiejar"
"net/http/httputil"
"net/url"
"os"
Expand Down Expand Up @@ -81,14 +82,22 @@ func Run(ctx context.Context, config *Suo5Config) error {
}
log.Infof("using redirect url %v", config.RedirectURL)
}
var jar *cookiejar.Jar
if !config.DisableCookiejar {
jar, _ = cookiejar.New(nil)
}

noTimeoutClient := &http.Client{
Transport: tr.Clone(),
Jar: jar,
Timeout: 0,
}
normalClient := &http.Client{
Timeout: time.Duration(config.Timeout) * time.Second,
Jar: jar,
Transport: tr.Clone(),
}
// todo: support cookiejar
rawClient := newRawClient(config.UpstreamProxy, 0)

log.Infof("header: %s", config.headerString())
Expand Down
62 changes: 36 additions & 26 deletions gui/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions gui/frontend/src/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,29 @@
<n-form label-width="85"
label-placement="left"
size="small">
<n-grid :cols="6">
<n-gi span="1">
<n-grid :cols="2">
<n-gi span="2">
<n-form-item label="调试模式">
<n-checkbox v-model:checked="advancedOptions.debug"></n-checkbox>
</n-form-item>
</n-gi>
<n-gi span="2" offset="1">
<n-form-item label-width="100" label="禁用gzip压缩" >
<n-checkbox v-model:checked="advancedOptions.disable_gzip"></n-checkbox>
</n-form-item>
</n-gi>
</n-grid>
<n-grid :cols="6">
<n-gi span="1">
<n-form-item label="禁用心跳包">
<n-checkbox v-model:checked="advancedOptions.disable_heartbeat"></n-checkbox>
</n-form-item>
</n-gi>
<n-gi span="2" offset="1">
<n-form-item label-width="120" label="禁用CookieJar">
<n-checkbox v-model:checked="advancedOptions.disable_cookiejar"></n-checkbox>
</n-form-item>
</n-gi>
<n-gi span="2">
<n-form-item label-width="100" label="禁用Gzip压缩" >
<n-checkbox v-model:checked="advancedOptions.disable_gzip"></n-checkbox>
</n-form-item>
</n-gi>
</n-grid>
<n-grid :cols="2">
<n-gi>
Expand Down Expand Up @@ -170,6 +177,7 @@ const formValue = ref<ctrl.Suo5Config>({
raw_header: [],
disable_heartbeat: false,
disable_gzip: false,
disable_cookiejar: false,
})
const advancedOptions = ref<ctrl.Suo5Config>(Object.assign({}, formValue.value))
Expand Down Expand Up @@ -198,6 +206,7 @@ const confirmAdvanced = () => {
formValue.value.redirect_url = advancedOptions.value.redirect_url
formValue.value.disable_heartbeat = advancedOptions.value.disable_heartbeat
formValue.value.disable_gzip = advancedOptions.value.disable_gzip
formValue.value.disable_cookiejar = advancedOptions.value.disable_cookiejar
showAdvanced.value = false
}
const formRef = ref<FormInst | null>(null)
Expand Down
2 changes: 2 additions & 0 deletions gui/frontend/wailsjs/go/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export namespace ctrl {
raw_header: string[];
disable_heartbeat: boolean;
disable_gzip: boolean;
disable_cookiejar: boolean;

static createFrom(source: any = {}) {
return new Suo5Config(source);
Expand All @@ -38,6 +39,7 @@ export namespace ctrl {
this.raw_header = source["raw_header"];
this.disable_heartbeat = source["disable_heartbeat"];
this.disable_gzip = source["disable_gzip"];
this.disable_cookiejar = source["disable_cookiejar"];
}
}

Expand Down
37 changes: 18 additions & 19 deletions gui/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,51 @@ go 1.18

require (
github.com/shirou/gopsutil/v3 v3.23.4
github.com/wailsapp/wails/v2 v2.5.1
github.com/wailsapp/wails/v2 v2.6.0
github.com/zema1/suo5 v0.0.0-00010101000000-000000000000
)

require (
github.com/Mzack9999/go-http-digest-auth-client v0.6.1-0.20220414142836-eb8883508809 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/bep/debounce v1.2.1 // indirect
github.com/gaukas/godicttls v0.0.4 // indirect
github.com/go-gost/gosocks5 v0.3.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
github.com/kataras/golog v0.1.8 // indirect
github.com/kataras/pio v0.0.11 // indirect
github.com/labstack/echo/v4 v4.10.2 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/leaanthony/go-ansi-parser v1.6.0 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/labstack/echo/v4 v4.11.3 // indirect
github.com/labstack/gommon v0.4.1 // indirect
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
github.com/leaanthony/gosod v1.0.3 // indirect
github.com/leaanthony/slicer v1.6.0 // indirect
github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/microcosm-cc/bluemonday v1.0.24 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
github.com/projectdiscovery/retryablehttp-go v1.0.16 // indirect
github.com/projectdiscovery/utils v0.0.32 // indirect
github.com/quic-go/quic-go v0.38.0 // indirect
github.com/refraction-networking/utls v1.4.3 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/samber/lo v1.38.1 // indirect
github.com/shoenig/go-m1cpu v0.1.5 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/tkrajina/go-reflector v0.5.6 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/wailsapp/go-webview2 v1.0.10 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
github.com/zema1/rawhttp v0.0.0-20230822073911-623d3e35433f // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
)

// replace github.com/wailsapp/wails/v2 v2.2.0 => C:\Users\Koalr\go\pkg\mod
Expand Down
Loading

0 comments on commit b4fc205

Please sign in to comment.