Fan Lin
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with
79 additions and
79 deletions
-
Makefile
-
component/simple-obfs/http.go
-
component/simple-obfs/tls.go
-
constant/metadata.go
-
core/device/fd/fd_unix.go
-
core/device/fd/fd_windows.go
-
core/device/fd/open_linux.go
-
core/device/fd/open_others.go
-
core/device/tun/io_unix.go
-
core/device/tun/tun.go
-
core/device/tun/tun_gvisor.go
-
core/device/tun/tun_wireguard.go
-
core/stack/stack.go
-
engine/engine.go
-
engine/parse.go
-
engine/tunnel.go
-
engine/version.go
-
go.mod
-
log/event.go
-
main.go
-
proxy/base.go
-
proxy/direct.go
-
proxy/http.go
-
proxy/proxy.go
-
proxy/reject.go
-
proxy/shadowsocks.go
-
proxy/socks4.go
-
proxy/socks5.go
-
stats/connections.go
-
stats/server.go
-
tunnel/statistic/tracker.go
-
tunnel/tcp.go
-
tunnel/tunnel.go
-
tunnel/udp.go
|
|
@ -1,5 +1,5 @@ |
|
|
|
BINARY := tun2socks |
|
|
|
MODULE := github.com/xjasonlyu/tun2socks |
|
|
|
MODULE := github.com/xjasonlyu/tun2socks/v2 |
|
|
|
|
|
|
|
BUILD_DIR := build |
|
|
|
BUILD_TAGS := |
|
|
|
|
|
@ -9,7 +9,7 @@ import ( |
|
|
|
"net" |
|
|
|
"net/http" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/common/pool" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/common/pool" |
|
|
|
) |
|
|
|
|
|
|
|
// HTTPObfs is shadowsocks http simple-obfs implementation
|
|
|
|
|
|
@ -8,7 +8,7 @@ import ( |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/common/pool" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/common/pool" |
|
|
|
) |
|
|
|
|
|
|
|
func init() { |
|
|
|
|
|
@ -7,7 +7,7 @@ import ( |
|
|
|
"net" |
|
|
|
"strconv" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/transport/socks5" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/transport/socks5" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
@ -6,7 +6,7 @@ import ( |
|
|
|
"fmt" |
|
|
|
"strconv" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device" |
|
|
|
"golang.org/x/sys/unix" |
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/stack" |
|
|
|
) |
|
|
|
|
|
@ -3,7 +3,7 @@ package fd |
|
|
|
import ( |
|
|
|
"errors" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device" |
|
|
|
) |
|
|
|
|
|
|
|
func Open(name string, mtu uint32) (device.Device, error) { |
|
|
|
|
|
@ -3,7 +3,7 @@ package fd |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device" |
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/link/fdbased" |
|
|
|
) |
|
|
|
|
|
|
|
|
|
@ -6,8 +6,8 @@ import ( |
|
|
|
"fmt" |
|
|
|
"os" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/core/device/rwbased" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device/rwbased" |
|
|
|
) |
|
|
|
|
|
|
|
func open(fd int, mtu uint32) (device.Device, error) { |
|
|
|
|
|
@ -3,7 +3,7 @@ |
|
|
|
package tun |
|
|
|
|
|
|
|
import ( |
|
|
|
"github.com/xjasonlyu/tun2socks/common/pool" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/common/pool" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
@ -2,7 +2,7 @@ |
|
|
|
package tun |
|
|
|
|
|
|
|
import ( |
|
|
|
"github.com/xjasonlyu/tun2socks/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device" |
|
|
|
) |
|
|
|
|
|
|
|
const Driver = "tun" |
|
|
|
|
|
@ -6,7 +6,7 @@ import ( |
|
|
|
"fmt" |
|
|
|
"unsafe" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device" |
|
|
|
|
|
|
|
"golang.org/x/sys/unix" |
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/link/fdbased" |
|
|
|
|
|
@ -5,8 +5,8 @@ package tun |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/core/device/rwbased" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device/rwbased" |
|
|
|
|
|
|
|
"golang.zx2c4.com/wireguard/tun" |
|
|
|
) |
|
|
|
|
|
@ -2,7 +2,7 @@ |
|
|
|
package stack |
|
|
|
|
|
|
|
import ( |
|
|
|
"github.com/xjasonlyu/tun2socks/core" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core" |
|
|
|
|
|
|
|
"gvisor.dev/gvisor/pkg/tcpip" |
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/network/ipv4" |
|
|
|
|
|
@ -4,13 +4,13 @@ import ( |
|
|
|
"errors" |
|
|
|
"os" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/component/dialer" |
|
|
|
"github.com/xjasonlyu/tun2socks/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/core/stack" |
|
|
|
"github.com/xjasonlyu/tun2socks/log" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy" |
|
|
|
"github.com/xjasonlyu/tun2socks/stats" |
|
|
|
"github.com/xjasonlyu/tun2socks/tunnel" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/component/dialer" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/stack" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/log" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/stats" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/tunnel" |
|
|
|
|
|
|
|
"gopkg.in/yaml.v3" |
|
|
|
) |
|
|
|
|
|
@ -6,11 +6,11 @@ import ( |
|
|
|
"net/url" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/core/device/fd" |
|
|
|
"github.com/xjasonlyu/tun2socks/core/device/tun" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy/proto" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device/fd" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device/tun" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy/proto" |
|
|
|
) |
|
|
|
|
|
|
|
func parseDevice(s string, mtu uint32) (device.Device, error) { |
|
|
|
|
|
@ -1,8 +1,8 @@ |
|
|
|
package engine |
|
|
|
|
|
|
|
import ( |
|
|
|
"github.com/xjasonlyu/tun2socks/core" |
|
|
|
"github.com/xjasonlyu/tun2socks/tunnel" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/tunnel" |
|
|
|
) |
|
|
|
|
|
|
|
var _ core.Handler = (*fakeTunnel)(nil) |
|
|
|
|
|
@ -5,7 +5,7 @@ import ( |
|
|
|
"runtime" |
|
|
|
"strings" |
|
|
|
|
|
|
|
V "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
V "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
) |
|
|
|
|
|
|
|
func showVersion() { |
|
|
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
module github.com/xjasonlyu/tun2socks |
|
|
|
module github.com/xjasonlyu/tun2socks/v2 |
|
|
|
|
|
|
|
go 1.17 |
|
|
|
|
|
|
|
|
|
@ -4,7 +4,7 @@ import ( |
|
|
|
"fmt" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/common/observable" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/common/observable" |
|
|
|
) |
|
|
|
|
|
|
|
var ( |
|
|
|
|
|
@ -6,8 +6,8 @@ import ( |
|
|
|
"os/signal" |
|
|
|
"syscall" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/engine" |
|
|
|
"github.com/xjasonlyu/tun2socks/log" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/engine" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/log" |
|
|
|
) |
|
|
|
|
|
|
|
var key = new(engine.Key) |
|
|
|
|
|
@ -5,8 +5,8 @@ import ( |
|
|
|
"errors" |
|
|
|
"net" |
|
|
|
|
|
|
|
M "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy/proto" |
|
|
|
M "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy/proto" |
|
|
|
) |
|
|
|
|
|
|
|
var _ Proxy = (*Base)(nil) |
|
|
|
|
|
@ -4,9 +4,9 @@ import ( |
|
|
|
"context" |
|
|
|
"net" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/component/dialer" |
|
|
|
M "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy/proto" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/component/dialer" |
|
|
|
M "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy/proto" |
|
|
|
) |
|
|
|
|
|
|
|
var _ Proxy = (*Direct)(nil) |
|
|
|
|
|
@ -13,9 +13,9 @@ import ( |
|
|
|
"net/http" |
|
|
|
"net/url" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/component/dialer" |
|
|
|
M "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy/proto" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/component/dialer" |
|
|
|
M "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy/proto" |
|
|
|
) |
|
|
|
|
|
|
|
type HTTP struct { |
|
|
|
|
|
@ -6,8 +6,8 @@ import ( |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
|
|
|
|
M "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy/proto" |
|
|
|
M "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy/proto" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
@ -6,8 +6,8 @@ import ( |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
|
|
|
|
M "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy/proto" |
|
|
|
M "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy/proto" |
|
|
|
) |
|
|
|
|
|
|
|
var _ Proxy = (*Reject)(nil) |
|
|
|
|
|
@ -6,11 +6,11 @@ import ( |
|
|
|
"fmt" |
|
|
|
"net" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/component/dialer" |
|
|
|
obfs "github.com/xjasonlyu/tun2socks/component/simple-obfs" |
|
|
|
M "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy/proto" |
|
|
|
"github.com/xjasonlyu/tun2socks/transport/socks5" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/component/dialer" |
|
|
|
obfs "github.com/xjasonlyu/tun2socks/v2/component/simple-obfs" |
|
|
|
M "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy/proto" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/transport/socks5" |
|
|
|
|
|
|
|
"github.com/Dreamacro/go-shadowsocks2/core" |
|
|
|
) |
|
|
|
|
|
@ -5,10 +5,10 @@ import ( |
|
|
|
"fmt" |
|
|
|
"net" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/component/dialer" |
|
|
|
M "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy/proto" |
|
|
|
"github.com/xjasonlyu/tun2socks/transport/socks4" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/component/dialer" |
|
|
|
M "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy/proto" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/transport/socks4" |
|
|
|
) |
|
|
|
|
|
|
|
var _ Proxy = (*Socks4)(nil) |
|
|
|
|
|
@ -7,10 +7,10 @@ import ( |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/component/dialer" |
|
|
|
M "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy/proto" |
|
|
|
"github.com/xjasonlyu/tun2socks/transport/socks5" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/component/dialer" |
|
|
|
M "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy/proto" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/transport/socks5" |
|
|
|
) |
|
|
|
|
|
|
|
var _ Proxy = (*Socks5)(nil) |
|
|
|
|
|
@ -7,7 +7,7 @@ import ( |
|
|
|
"strconv" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/tunnel/statistic" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/tunnel/statistic" |
|
|
|
|
|
|
|
"github.com/go-chi/chi/v5" |
|
|
|
"github.com/go-chi/render" |
|
|
|
|
|
@ -8,9 +8,9 @@ import ( |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
|
|
|
|
V "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/log" |
|
|
|
"github.com/xjasonlyu/tun2socks/tunnel/statistic" |
|
|
|
V "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/log" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/tunnel/statistic" |
|
|
|
|
|
|
|
"github.com/go-chi/chi/v5" |
|
|
|
"github.com/go-chi/cors" |
|
|
|
|
|
@ -4,7 +4,7 @@ import ( |
|
|
|
"net" |
|
|
|
"time" |
|
|
|
|
|
|
|
M "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
M "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
|
|
|
|
"github.com/gofrs/uuid" |
|
|
|
"go.uber.org/atomic" |
|
|
|
|
|
@ -6,12 +6,12 @@ import ( |
|
|
|
"sync" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/common/pool" |
|
|
|
M "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/core" |
|
|
|
"github.com/xjasonlyu/tun2socks/log" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy" |
|
|
|
"github.com/xjasonlyu/tun2socks/tunnel/statistic" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/common/pool" |
|
|
|
M "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/log" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/tunnel/statistic" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
@ -3,8 +3,8 @@ package tunnel |
|
|
|
import ( |
|
|
|
"runtime" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/core" |
|
|
|
"github.com/xjasonlyu/tun2socks/log" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/log" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
@ -6,13 +6,13 @@ import ( |
|
|
|
"os" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/xjasonlyu/tun2socks/common/pool" |
|
|
|
"github.com/xjasonlyu/tun2socks/component/nat" |
|
|
|
M "github.com/xjasonlyu/tun2socks/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/core" |
|
|
|
"github.com/xjasonlyu/tun2socks/log" |
|
|
|
"github.com/xjasonlyu/tun2socks/proxy" |
|
|
|
"github.com/xjasonlyu/tun2socks/tunnel/statistic" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/common/pool" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/component/nat" |
|
|
|
M "github.com/xjasonlyu/tun2socks/v2/constant" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/log" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/proxy" |
|
|
|
"github.com/xjasonlyu/tun2socks/v2/tunnel/statistic" |
|
|
|
) |
|
|
|
|
|
|
|
var ( |
|
|
|