mirror of
https://github.com/go-gost/gost.git
synced 2026-10-08 20:15:46 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4c9ef5056 | ||
|
|
c06eb0d331 | ||
|
|
c8b48dc248 | ||
|
|
45d94cf391 |
+1
-1
@@ -35,6 +35,6 @@ cmd/gost/gost
|
|||||||
snap
|
snap
|
||||||
|
|
||||||
*.pem
|
*.pem
|
||||||
*.yaml
|
/*.yaml
|
||||||
*.txt
|
*.txt
|
||||||
dist/
|
dist/
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
_ "github.com/go-gost/x/connector/forward"
|
_ "github.com/go-gost/x/connector/forward"
|
||||||
_ "github.com/go-gost/x/connector/http"
|
_ "github.com/go-gost/x/connector/http"
|
||||||
_ "github.com/go-gost/x/connector/http2"
|
_ "github.com/go-gost/x/connector/http2"
|
||||||
|
_ "github.com/go-gost/x/connector/masque"
|
||||||
_ "github.com/go-gost/x/connector/relay"
|
_ "github.com/go-gost/x/connector/relay"
|
||||||
_ "github.com/go-gost/x/connector/router"
|
_ "github.com/go-gost/x/connector/router"
|
||||||
_ "github.com/go-gost/x/connector/serial"
|
_ "github.com/go-gost/x/connector/serial"
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
module github.com/go-gost/gost
|
module github.com/go-gost/gost
|
||||||
|
|
||||||
go 1.25.0
|
go 1.26.3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-gost/core v0.3.3
|
github.com/go-gost/core v0.4.0
|
||||||
github.com/go-gost/x v0.9.0
|
github.com/go-gost/x v0.10.0
|
||||||
github.com/judwhite/go-svc v1.2.1
|
github.com/judwhite/go-svc v1.2.1
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,11 +28,11 @@ require (
|
|||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
github.com/gin-gonic/gin v1.10.1 // indirect
|
github.com/gin-gonic/gin v1.10.1 // indirect
|
||||||
github.com/go-gost/go-shadowsocks2 v0.1.2 // indirect
|
github.com/go-gost/go-shadowsocks2 v0.1.2 // indirect
|
||||||
github.com/go-gost/gosocks4 v0.0.1 // indirect
|
github.com/go-gost/gosocks4 v0.1.0 // indirect
|
||||||
github.com/go-gost/gosocks5 v0.4.2 // indirect
|
github.com/go-gost/gosocks5 v0.5.0 // indirect
|
||||||
github.com/go-gost/plugin v0.2.1 // indirect
|
github.com/go-gost/plugin v0.3.0 // indirect
|
||||||
github.com/go-gost/relay v0.5.0 // indirect
|
github.com/go-gost/relay v0.6.0 // indirect
|
||||||
github.com/go-gost/tls-dissector v0.1.1 // indirect
|
github.com/go-gost/tls-dissector v0.2.0 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||||
|
|||||||
@@ -49,22 +49,22 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
|
|||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||||
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
|
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
|
||||||
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||||
github.com/go-gost/core v0.3.3 h1:YN15FQptQoNB0MlMR283C99w2EeGql9Cm+4QVlN6zs0=
|
github.com/go-gost/core v0.4.0 h1:jLuIMO7ZMJX/BDCYLrYXAmIykT+HkqEuzaTeLMdrY1c=
|
||||||
github.com/go-gost/core v0.3.3/go.mod h1:WGI43jOka7FAsSAwi/fSMaqxdR+E339ycb4NBGlFr6A=
|
github.com/go-gost/core v0.4.0/go.mod h1:WGI43jOka7FAsSAwi/fSMaqxdR+E339ycb4NBGlFr6A=
|
||||||
github.com/go-gost/go-shadowsocks2 v0.1.2 h1:qgTUQS6aCGzsFArjiKjLP0a7zEVtEYVCRVc5LjOsaVk=
|
github.com/go-gost/go-shadowsocks2 v0.1.2 h1:qgTUQS6aCGzsFArjiKjLP0a7zEVtEYVCRVc5LjOsaVk=
|
||||||
github.com/go-gost/go-shadowsocks2 v0.1.2/go.mod h1:866zFNNI3He6Wef1M/IvAjTal74WhcfKfBgRpTlkKys=
|
github.com/go-gost/go-shadowsocks2 v0.1.2/go.mod h1:866zFNNI3He6Wef1M/IvAjTal74WhcfKfBgRpTlkKys=
|
||||||
github.com/go-gost/gosocks4 v0.0.1 h1:+k1sec8HlELuQV7rWftIkmy8UijzUt2I6t+iMPlGB2s=
|
github.com/go-gost/gosocks4 v0.1.0 h1:eAzev6qw4fzkFQKC9uCHLVNnnPdHyqCggbnfNN80Pmk=
|
||||||
github.com/go-gost/gosocks4 v0.0.1/go.mod h1:3B6L47HbU/qugDg4JnoFPHgJXE43Inz8Bah1QaN9qCc=
|
github.com/go-gost/gosocks4 v0.1.0/go.mod h1:hzVjwijJuZR1pp3GqpTj+AKcSGrx68RlWTrQMFMYBP0=
|
||||||
github.com/go-gost/gosocks5 v0.4.2 h1:IianxHTkACPqCwiOAT3MHoMdSUl+SEPSRu1ikawC1Pc=
|
github.com/go-gost/gosocks5 v0.5.0 h1:YE37l1MJwde8diIQdynStqogMotG5enoTdborhA5yic=
|
||||||
github.com/go-gost/gosocks5 v0.4.2/go.mod h1:1G6I7HP7VFVxveGkoK8mnprnJqSqJjdcASKsdUn4Pp4=
|
github.com/go-gost/gosocks5 v0.5.0/go.mod h1:1G6I7HP7VFVxveGkoK8mnprnJqSqJjdcASKsdUn4Pp4=
|
||||||
github.com/go-gost/plugin v0.2.1 h1:zkkgCZd+/X+jmaDElP7z2fZVTFv+Pjq2DLmnnNWPMFA=
|
github.com/go-gost/plugin v0.3.0 h1:pmll8nNd9PX92BWMB5+b2y2SEkBAWJLxD2ANfX+WHuw=
|
||||||
github.com/go-gost/plugin v0.2.1/go.mod h1:oN23l+yGDCIP9G3KnDl/I/0zVGOobZUDCB2Z5yYYXts=
|
github.com/go-gost/plugin v0.3.0/go.mod h1:oN23l+yGDCIP9G3KnDl/I/0zVGOobZUDCB2Z5yYYXts=
|
||||||
github.com/go-gost/relay v0.5.0 h1:JG1tgy/KWiVXS0ukuVXvbM0kbYuJTWxYpJ5JwzsCf/c=
|
github.com/go-gost/relay v0.6.0 h1:o8r0B3eTw8Rwwent+5x5Cw1g4AyNUl4hNqiyDJXkFvA=
|
||||||
github.com/go-gost/relay v0.5.0/go.mod h1:lcX+23LCQ3khIeASBo+tJ/WbwXFO32/N5YN6ucuYTG8=
|
github.com/go-gost/relay v0.6.0/go.mod h1:Dku0f5sfjOClrZFiDmQUrYYJ4uof7rnkCUBfsl0PSAI=
|
||||||
github.com/go-gost/tls-dissector v0.1.1 h1:2zUOTPzCQAUQ54Rpy0UEi3JPMQSYsIFSeFeKrzmkCoU=
|
github.com/go-gost/tls-dissector v0.2.0 h1:9tE6WOzzpurATTBWn60DU4R8gibpGNY8/qVcc1SicVg=
|
||||||
github.com/go-gost/tls-dissector v0.1.1/go.mod h1:/9QfdewqmHdaE362Hv5nDaSWLx3pCmtD870d6GaquXs=
|
github.com/go-gost/tls-dissector v0.2.0/go.mod h1:/9QfdewqmHdaE362Hv5nDaSWLx3pCmtD870d6GaquXs=
|
||||||
github.com/go-gost/x v0.9.0 h1:leSBi3tr6LfW5ab2ZbkH1/ZFc2NNVHm6uRAKqL2Ulkk=
|
github.com/go-gost/x v0.10.0 h1:bPcmXQ7YvwfgqsHxdQSEcuq6orPIEQmVVEGcDG+HAhY=
|
||||||
github.com/go-gost/x v0.9.0/go.mod h1:PJLyFVh5NcE5OhEk7/AQi+29VnKJXjgd0ah19laW6Ec=
|
github.com/go-gost/x v0.10.0/go.mod h1:P7iASIn28XVNlENQTdJ8bUkRHcrObjuxd7UUjxK/PaY=
|
||||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ install_gost() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
get_download_url="$base_url/tags/$version"
|
get_download_url="$base_url/tags/$version"
|
||||||
download_url=$(curl -s "$get_download_url" | awk -F'"' -v re=".*${os}.*${cpu_arch}.*" '/"browser_download_url":/ && $4 ~ re { print $4 }')
|
download_url=$(curl -s "$get_download_url" | awk -F'"' -v re=".*${os}.*${cpu_arch}.*" '/"browser_download_url":/ && $4 ~ re { print $4 }' | head -n 1)
|
||||||
|
|
||||||
# Download and install the binary
|
# Download and install the binary
|
||||||
install_path="/usr/local/bin"
|
install_path="/usr/local/bin"
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
FROM alpine:3.22
|
||||||
|
|
||||||
|
# add iptables for tun/tap and curl for testing
|
||||||
|
RUN apk add --no-cache iptables curl
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package e2e
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/testcontainers/testcontainers-go/network"
|
||||||
|
)
|
||||||
|
|
||||||
|
var SharedNetworkName string
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
// Compile the gost binary
|
||||||
|
cmd := exec.Command("go", "build", "-o", "/tmp/gost-test-bin", "../../cmd/gost")
|
||||||
|
cmd.Env = append(os.Environ(), "CGO_ENABLED=0")
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
fmt.Printf("Failed to compile gost: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
os.Remove("/tmp/gost-test-bin")
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Create a shared Docker network
|
||||||
|
net, err := network.New(ctx)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Failed to create network: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
SharedNetworkName = net.Name
|
||||||
|
|
||||||
|
// Run tests
|
||||||
|
code := m.Run()
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
net.Remove(ctx)
|
||||||
|
|
||||||
|
os.Exit(code)
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package e2e
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
"github.com/testcontainers/testcontainers-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ParallelSelectorSuite struct {
|
||||||
|
suite.Suite
|
||||||
|
ctx context.Context
|
||||||
|
echoC testcontainers.Container
|
||||||
|
echoIP string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ParallelSelectorSuite) SetupSuite() {
|
||||||
|
s.ctx = context.Background()
|
||||||
|
|
||||||
|
echoC, err := RunEchoContainer(s.ctx, SharedNetworkName)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
s.echoC = echoC
|
||||||
|
|
||||||
|
echoIP, err := echoC.ContainerIP(s.ctx)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
s.echoIP = echoIP
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ParallelSelectorSuite) TearDownSuite() {
|
||||||
|
if s.echoC != nil {
|
||||||
|
s.echoC.Terminate(s.ctx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ParallelSelectorSuite) TestParallelSelector() {
|
||||||
|
gostC, err := RunGostContainer(s.ctx, SharedNetworkName, "testdata/parallel_selector/server.yaml")
|
||||||
|
s.Require().NoError(err)
|
||||||
|
defer gostC.Terminate(s.ctx)
|
||||||
|
|
||||||
|
// Test the proxy by running curl inside the gost container
|
||||||
|
cmd := []string{"curl", "-v", "-s", "-x", "http://127.0.0.1:8080", fmt.Sprintf("http://%s:5678", s.echoIP)}
|
||||||
|
code, out, err := gostC.Exec(s.ctx, cmd)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
body, err := io.ReadAll(out)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
s.Require().Equal(0, code)
|
||||||
|
|
||||||
|
s.Require().Contains(string(body), "hello-gost")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParallelSelectorSuite(t *testing.T) {
|
||||||
|
suite.Run(t, new(ParallelSelectorSuite))
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
services:
|
||||||
|
- name: proxy
|
||||||
|
addr: :8080
|
||||||
|
handler:
|
||||||
|
type: http
|
||||||
|
chain: my-chain
|
||||||
|
listener:
|
||||||
|
type: tcp
|
||||||
|
|
||||||
|
- name: dummy-1
|
||||||
|
addr: :18081
|
||||||
|
handler:
|
||||||
|
type: http
|
||||||
|
|
||||||
|
chains:
|
||||||
|
- name: my-chain
|
||||||
|
hops:
|
||||||
|
- name: hop-1
|
||||||
|
selector:
|
||||||
|
strategy: parallel
|
||||||
|
nodes:
|
||||||
|
- name: node-1
|
||||||
|
addr: 127.0.0.1:18081
|
||||||
|
connector:
|
||||||
|
type: http
|
||||||
|
# non existed node
|
||||||
|
- name: node-2
|
||||||
|
addr: 127.0.0.1:18082
|
||||||
|
connector:
|
||||||
|
type: http
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package e2e
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/testcontainers/testcontainers-go"
|
||||||
|
"github.com/testcontainers/testcontainers-go/wait"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RunEchoContainer(ctx context.Context, networkName string) (testcontainers.Container, error) {
|
||||||
|
req := testcontainers.ContainerRequest{
|
||||||
|
Image: "hashicorp/http-echo:latest",
|
||||||
|
Networks: []string{networkName},
|
||||||
|
Cmd: []string{"-text=hello-gost", "-listen=:5678"},
|
||||||
|
ExposedPorts: []string{"5678/tcp"},
|
||||||
|
WaitingFor: wait.ForHTTP("/").WithPort("5678/tcp"),
|
||||||
|
}
|
||||||
|
return testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
|
||||||
|
ContainerRequest: req,
|
||||||
|
Started: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func RunGostContainer(ctx context.Context, networkName, yamlPath string) (testcontainers.Container, error) {
|
||||||
|
req := testcontainers.ContainerRequest{
|
||||||
|
FromDockerfile: testcontainers.FromDockerfile{
|
||||||
|
Context: ".",
|
||||||
|
Dockerfile: "Dockerfile",
|
||||||
|
Repo: "gost-e2e",
|
||||||
|
Tag: "latest",
|
||||||
|
KeepImage: true,
|
||||||
|
},
|
||||||
|
Networks: []string{networkName},
|
||||||
|
Files: []testcontainers.ContainerFile{
|
||||||
|
{HostFilePath: "/tmp/gost-test-bin", ContainerFilePath: "/bin/gost", FileMode: 0755},
|
||||||
|
{HostFilePath: yamlPath, ContainerFilePath: "/config.yaml", FileMode: 0644},
|
||||||
|
},
|
||||||
|
Cmd: []string{"/bin/gost", "-C", "/config.yaml"},
|
||||||
|
}
|
||||||
|
return testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
|
||||||
|
ContainerRequest: req,
|
||||||
|
Started: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user