mirror of
https://github.com/cedar2025/hysteria.git
synced 2025-07-04 02:09:51 +00:00
format: gofumpt
This commit is contained in:
parent
4747be198e
commit
1462cadfdc
@ -3,11 +3,13 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
|
||||
"github.com/caddyserver/certmagic"
|
||||
)
|
||||
|
||||
func acmeTLSConfig(domains []string, email string, disableHTTP bool, disableTLSALPN bool,
|
||||
altHTTPPort int, altTLSALPNPort int) (*tls.Config, error) {
|
||||
altHTTPPort int, altTLSALPNPort int,
|
||||
) (*tls.Config, error) {
|
||||
certmagic.DefaultACME.Agreed = true
|
||||
certmagic.DefaultACME.Email = email
|
||||
certmagic.DefaultACME.DisableHTTPChallenge = disableHTTP
|
||||
|
@ -1,11 +1,12 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type CmdAuthProvider struct {
|
||||
|
@ -3,10 +3,11 @@ package auth
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/sirupsen/logrus"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type HTTPAuthProvider struct {
|
||||
|
@ -4,10 +4,6 @@ import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
"github.com/tobyxdd/hysteria/pkg/pmtud_fix"
|
||||
"github.com/tobyxdd/hysteria/pkg/redirect"
|
||||
"github.com/yosuke-furukawa/json5/encoding/json5"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
@ -15,6 +11,11 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
"github.com/tobyxdd/hysteria/pkg/pmtud_fix"
|
||||
"github.com/tobyxdd/hysteria/pkg/redirect"
|
||||
"github.com/yosuke-furukawa/json5/encoding/json5"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/lucas-clemente/quic-go/congestion"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -4,13 +4,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"github.com/tobyxdd/hysteria/pkg/tun"
|
||||
"io"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"github.com/tobyxdd/hysteria/pkg/tun"
|
||||
)
|
||||
|
||||
const license = `Hysteria is a feature-packed proxy & relay utility optimized for lossy, unstable connections.
|
||||
|
@ -3,11 +3,12 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/yosuke-furukawa/json5/encoding/json5"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/yosuke-furukawa/json5/encoding/json5"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -2,9 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"sync"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/sirupsen/logrus"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type keypairLoader struct {
|
||||
|
@ -1,12 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/viper"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func downloadMMDB(filename string) error {
|
||||
|
@ -2,10 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
rdns "github.com/folbricht/routedns"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
rdns "github.com/folbricht/routedns"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
)
|
||||
|
||||
var errInvalidSyntax = errors.New("invalid syntax")
|
||||
|
@ -3,6 +3,11 @@ package main
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/lucas-clemente/quic-go/congestion"
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
@ -18,10 +23,6 @@ import (
|
||||
"github.com/tobyxdd/hysteria/pkg/sockopt"
|
||||
"github.com/tobyxdd/hysteria/pkg/transport"
|
||||
"github.com/yosuke-furukawa/json5/encoding/json5"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func server(config *serverConfig) {
|
||||
|
@ -2,12 +2,13 @@ package acl
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
)
|
||||
|
||||
const entryCacheSize = 1024
|
||||
|
@ -2,10 +2,11 @@ package acl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"net"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
)
|
||||
|
||||
func TestEngine_ResolveAndMatch(t *testing.T) {
|
||||
|
@ -3,14 +3,17 @@ package acl
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
)
|
||||
|
||||
type Action byte
|
||||
type Protocol byte
|
||||
type (
|
||||
Action byte
|
||||
Protocol byte
|
||||
)
|
||||
|
||||
const (
|
||||
ActionDirect = Action(iota)
|
||||
|
@ -19,46 +19,64 @@ func TestParseEntry(t *testing.T) {
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "empty", args: args{""}, want: Entry{}, wantErr: true},
|
||||
{name: "ok 1", args: args{"direct domain-suffix google.com"},
|
||||
{
|
||||
name: "ok 1", args: args{"direct domain-suffix google.com"},
|
||||
want: Entry{ActionDirect, "", &domainMatcher{
|
||||
matcherBase: matcherBase{},
|
||||
Domain: "google.com",
|
||||
Suffix: true,
|
||||
}},
|
||||
wantErr: false},
|
||||
{name: "ok 2", args: args{"proxy domain shithole"},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "ok 2", args: args{"proxy domain shithole"},
|
||||
want: Entry{ActionProxy, "", &domainMatcher{
|
||||
matcherBase: matcherBase{},
|
||||
Domain: "shithole",
|
||||
Suffix: false,
|
||||
}},
|
||||
wantErr: false},
|
||||
{name: "ok 3", args: args{"block cidr 8.8.8.0/24 */53"},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "ok 3", args: args{"block cidr 8.8.8.0/24 */53"},
|
||||
want: Entry{ActionBlock, "", &netMatcher{
|
||||
matcherBase: matcherBase{ProtocolAll, 53},
|
||||
Net: ok3net,
|
||||
}},
|
||||
wantErr: false},
|
||||
{name: "ok 4", args: args{"hijack all udp/* udpblackhole.net"},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "ok 4", args: args{"hijack all udp/* udpblackhole.net"},
|
||||
want: Entry{ActionHijack, "udpblackhole.net", &allMatcher{
|
||||
matcherBase: matcherBase{ProtocolUDP, 0},
|
||||
}},
|
||||
wantErr: false},
|
||||
{name: "err 1", args: args{"what the heck"},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "err 1", args: args{"what the heck"},
|
||||
want: Entry{},
|
||||
wantErr: true},
|
||||
{name: "err 2", args: args{"proxy sucks ass"},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "err 2", args: args{"proxy sucks ass"},
|
||||
want: Entry{},
|
||||
wantErr: true},
|
||||
{name: "err 3", args: args{"block ip 999.999.999.999"},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "err 3", args: args{"block ip 999.999.999.999"},
|
||||
want: Entry{},
|
||||
wantErr: true},
|
||||
{name: "err 4", args: args{"hijack domain google.com"},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "err 4", args: args{"hijack domain google.com"},
|
||||
want: Entry{},
|
||||
wantErr: true},
|
||||
{name: "err 5", args: args{"hijack domain google.com bing.com 123"},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "err 5", args: args{"hijack domain google.com bing.com 123"},
|
||||
want: Entry{},
|
||||
wantErr: true},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
@ -1,8 +1,9 @@
|
||||
package congestion
|
||||
|
||||
import (
|
||||
"github.com/lucas-clemente/quic-go/congestion"
|
||||
"time"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/congestion"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -66,12 +67,14 @@ func (b *BrutalSender) GetCongestionWindow() congestion.ByteCount {
|
||||
}
|
||||
|
||||
func (b *BrutalSender) OnPacketSent(sentTime time.Time, bytesInFlight congestion.ByteCount,
|
||||
packetNumber congestion.PacketNumber, bytes congestion.ByteCount, isRetransmittable bool) {
|
||||
packetNumber congestion.PacketNumber, bytes congestion.ByteCount, isRetransmittable bool,
|
||||
) {
|
||||
b.pacer.SentPacket(sentTime, bytes)
|
||||
}
|
||||
|
||||
func (b *BrutalSender) OnPacketAcked(number congestion.PacketNumber, ackedBytes congestion.ByteCount,
|
||||
priorInFlight congestion.ByteCount, eventTime time.Time) {
|
||||
priorInFlight congestion.ByteCount, eventTime time.Time,
|
||||
) {
|
||||
currentTimestamp := eventTime.Unix()
|
||||
slot := currentTimestamp % pktInfoSlotCount
|
||||
if b.pktInfoSlots[slot].Timestamp == currentTimestamp {
|
||||
@ -86,7 +89,8 @@ func (b *BrutalSender) OnPacketAcked(number congestion.PacketNumber, ackedBytes
|
||||
}
|
||||
|
||||
func (b *BrutalSender) OnPacketLost(number congestion.PacketNumber, lostBytes congestion.ByteCount,
|
||||
priorInFlight congestion.ByteCount) {
|
||||
priorInFlight congestion.ByteCount,
|
||||
) {
|
||||
currentTimestamp := time.Now().Unix()
|
||||
slot := currentTimestamp % pktInfoSlotCount
|
||||
if b.pktInfoSlots[slot].Timestamp == currentTimestamp {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package congestion
|
||||
|
||||
import (
|
||||
"github.com/lucas-clemente/quic-go/congestion"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/congestion"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -1,11 +1,12 @@
|
||||
package faketcp
|
||||
|
||||
import (
|
||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||
"net"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||
)
|
||||
|
||||
const udpBufferSize = 65535
|
||||
|
@ -11,12 +11,14 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
//const testPortStream = "127.0.0.1:3456"
|
||||
//const testPortPacket = "127.0.0.1:3457"
|
||||
// const testPortStream = "127.0.0.1:3456"
|
||||
// const testPortPacket = "127.0.0.1:3457"
|
||||
|
||||
const testPortStream = "127.0.0.1:3456"
|
||||
const portServerPacket = "[::]:3457"
|
||||
const portRemotePacket = "127.0.0.1:3457"
|
||||
const (
|
||||
testPortStream = "127.0.0.1:3456"
|
||||
portServerPacket = "[::]:3457"
|
||||
portRemotePacket = "127.0.0.1:3457"
|
||||
)
|
||||
|
||||
func init() {
|
||||
startTCPServer()
|
||||
@ -70,7 +72,7 @@ func startTCPRawServer() *TCPConn {
|
||||
log.Println("server readfrom:", err)
|
||||
return
|
||||
}
|
||||
//echo
|
||||
// echo
|
||||
n, err = conn.WriteTo(buf[:n], addr)
|
||||
if err != nil {
|
||||
log.Println("server writeTo:", err)
|
||||
|
@ -1,12 +1,13 @@
|
||||
package udp
|
||||
|
||||
import (
|
||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||
"net"
|
||||
"os"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||
)
|
||||
|
||||
const udpBufferSize = 65535
|
||||
|
@ -2,13 +2,14 @@ package wechat
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||
)
|
||||
|
||||
const udpBufferSize = 65535
|
||||
|
@ -6,6 +6,12 @@ import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/lucas-clemente/quic-go/congestion"
|
||||
"github.com/lunixbochs/struc"
|
||||
@ -13,16 +19,9 @@ import (
|
||||
"github.com/tobyxdd/hysteria/pkg/pmtud_fix"
|
||||
"github.com/tobyxdd/hysteria/pkg/transport"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
"math/rand"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrClosed = errors.New("closed")
|
||||
)
|
||||
var ErrClosed = errors.New("closed")
|
||||
|
||||
type CongestionFactory func(refBPS uint64) congestion.CongestionControl
|
||||
|
||||
@ -49,7 +48,8 @@ type Client struct {
|
||||
|
||||
func NewClient(serverAddr string, protocol string, auth []byte, tlsConfig *tls.Config, quicConfig *quic.Config,
|
||||
transport *transport.ClientTransport, sendBPS uint64, recvBPS uint64, congestionFactory CongestionFactory,
|
||||
obfuscator obfs.Obfuscator) (*Client, error) {
|
||||
obfuscator obfs.Obfuscator,
|
||||
) (*Client, error) {
|
||||
quicConfig.DisablePathMTUDiscovery = quicConfig.DisablePathMTUDiscovery || pmtud_fix.DisablePathMTUDiscovery
|
||||
c := &Client{
|
||||
transport: transport,
|
||||
|
@ -32,7 +32,7 @@ func Test_fragUDPMessage(t *testing.T) {
|
||||
100,
|
||||
},
|
||||
[]udpMessage{
|
||||
udpMessage{
|
||||
{
|
||||
SessionID: 123,
|
||||
HostLen: 4,
|
||||
Host: "test",
|
||||
@ -62,7 +62,7 @@ func Test_fragUDPMessage(t *testing.T) {
|
||||
22,
|
||||
},
|
||||
[]udpMessage{
|
||||
udpMessage{
|
||||
{
|
||||
SessionID: 123,
|
||||
HostLen: 4,
|
||||
Host: "test",
|
||||
@ -73,7 +73,7 @@ func Test_fragUDPMessage(t *testing.T) {
|
||||
DataLen: 4,
|
||||
Data: []byte("hell"),
|
||||
},
|
||||
udpMessage{
|
||||
{
|
||||
SessionID: 123,
|
||||
HostLen: 4,
|
||||
Host: "test",
|
||||
@ -103,7 +103,7 @@ func Test_fragUDPMessage(t *testing.T) {
|
||||
23,
|
||||
},
|
||||
[]udpMessage{
|
||||
udpMessage{
|
||||
{
|
||||
SessionID: 123,
|
||||
HostLen: 4,
|
||||
Host: "test",
|
||||
@ -114,7 +114,7 @@ func Test_fragUDPMessage(t *testing.T) {
|
||||
DataLen: 5,
|
||||
Data: []byte("wow w"),
|
||||
},
|
||||
udpMessage{
|
||||
{
|
||||
SessionID: 123,
|
||||
HostLen: 4,
|
||||
Host: "test",
|
||||
@ -125,7 +125,7 @@ func Test_fragUDPMessage(t *testing.T) {
|
||||
DataLen: 5,
|
||||
Data: []byte("ow wo"),
|
||||
},
|
||||
udpMessage{
|
||||
{
|
||||
SessionID: 123,
|
||||
HostLen: 4,
|
||||
Host: "test",
|
||||
@ -136,7 +136,7 @@ func Test_fragUDPMessage(t *testing.T) {
|
||||
DataLen: 5,
|
||||
Data: []byte("w lol"),
|
||||
},
|
||||
udpMessage{
|
||||
{
|
||||
SessionID: 123,
|
||||
HostLen: 4,
|
||||
Host: "test",
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/lunixbochs/struc"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@ -12,15 +14,16 @@ import (
|
||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||
"github.com/tobyxdd/hysteria/pkg/pmtud_fix"
|
||||
"github.com/tobyxdd/hysteria/pkg/transport"
|
||||
"net"
|
||||
)
|
||||
|
||||
type ConnectFunc func(addr net.Addr, auth []byte, sSend uint64, sRecv uint64) (bool, string)
|
||||
type DisconnectFunc func(addr net.Addr, auth []byte, err error)
|
||||
type TCPRequestFunc func(addr net.Addr, auth []byte, reqAddr string, action acl.Action, arg string)
|
||||
type TCPErrorFunc func(addr net.Addr, auth []byte, reqAddr string, err error)
|
||||
type UDPRequestFunc func(addr net.Addr, auth []byte, sessionID uint32)
|
||||
type UDPErrorFunc func(addr net.Addr, auth []byte, sessionID uint32, err error)
|
||||
type (
|
||||
ConnectFunc func(addr net.Addr, auth []byte, sSend uint64, sRecv uint64) (bool, string)
|
||||
DisconnectFunc func(addr net.Addr, auth []byte, err error)
|
||||
TCPRequestFunc func(addr net.Addr, auth []byte, reqAddr string, action acl.Action, arg string)
|
||||
TCPErrorFunc func(addr net.Addr, auth []byte, reqAddr string, err error)
|
||||
UDPRequestFunc func(addr net.Addr, auth []byte, sessionID uint32)
|
||||
UDPErrorFunc func(addr net.Addr, auth []byte, sessionID uint32, err error)
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
transport *transport.ServerTransport
|
||||
@ -46,7 +49,8 @@ func NewServer(addr string, protocol string, tlsConfig *tls.Config, quicConfig *
|
||||
sendBPS uint64, recvBPS uint64, congestionFactory CongestionFactory, disableUDP bool, aclEngine *acl.Engine,
|
||||
obfuscator obfs.Obfuscator, connectFunc ConnectFunc, disconnectFunc DisconnectFunc,
|
||||
tcpRequestFunc TCPRequestFunc, tcpErrorFunc TCPErrorFunc,
|
||||
udpRequestFunc UDPRequestFunc, udpErrorFunc UDPErrorFunc, promRegistry *prometheus.Registry) (*Server, error) {
|
||||
udpRequestFunc UDPRequestFunc, udpErrorFunc UDPErrorFunc, promRegistry *prometheus.Registry,
|
||||
) (*Server, error) {
|
||||
quicConfig.DisablePathMTUDiscovery = quicConfig.DisablePathMTUDiscovery || pmtud_fix.DisablePathMTUDiscovery
|
||||
listener, err := transport.QUICListen(protocol, addr, tlsConfig, quicConfig, obfuscator)
|
||||
if err != nil {
|
||||
|
@ -4,16 +4,17 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"math/rand"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/lunixbochs/struc"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/tobyxdd/hysteria/pkg/acl"
|
||||
"github.com/tobyxdd/hysteria/pkg/transport"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
"math/rand"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const udpBufferSize = 65535
|
||||
@ -44,7 +45,8 @@ func newServerClient(v2 bool, cs quic.Connection, tr *transport.ServerTransport,
|
||||
CTCPRequestFunc TCPRequestFunc, CTCPErrorFunc TCPErrorFunc,
|
||||
CUDPRequestFunc UDPRequestFunc, CUDPErrorFunc UDPErrorFunc,
|
||||
UpCounterVec, DownCounterVec *prometheus.CounterVec,
|
||||
ConnGaugeVec *prometheus.GaugeVec) *serverClient {
|
||||
ConnGaugeVec *prometheus.GaugeVec,
|
||||
) *serverClient {
|
||||
sc := &serverClient{
|
||||
V2: v2,
|
||||
CS: cs,
|
||||
|
@ -2,8 +2,9 @@ package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"time"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
)
|
||||
|
||||
// Handle stream close properly
|
||||
|
@ -3,12 +3,13 @@ package http
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/tobyxdd/hysteria/pkg/transport"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/transport"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
|
||||
"github.com/elazarl/goproxy/ext/auth"
|
||||
|
||||
"github.com/elazarl/goproxy"
|
||||
@ -18,7 +19,8 @@ import (
|
||||
|
||||
func NewProxyHTTPServer(hyClient *core.Client, transport *transport.ClientTransport, idleTimeout time.Duration,
|
||||
aclEngine *acl.Engine, newDialFunc func(reqAddr string, action acl.Action, arg string),
|
||||
basicAuthFunc func(user, password string) bool) (*goproxy.ProxyHttpServer, error) {
|
||||
basicAuthFunc func(user, password string) bool,
|
||||
) (*goproxy.ProxyHttpServer, error) {
|
||||
proxy := goproxy.NewProxyHttpServer()
|
||||
proxy.Logger = &nopLogger{}
|
||||
proxy.NonproxyHandler = http.NotFoundHandler()
|
||||
|
@ -3,11 +3,12 @@ package redirect
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
"net"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
)
|
||||
|
||||
type TCPRedirect struct {
|
||||
@ -21,7 +22,8 @@ type TCPRedirect struct {
|
||||
|
||||
func NewTCPRedirect(hyClient *core.Client, listen string, timeout time.Duration,
|
||||
connFunc func(addr, reqAddr net.Addr),
|
||||
errorFunc func(addr, reqAddr net.Addr, err error)) (*TCPRedirect, error) {
|
||||
errorFunc func(addr, reqAddr net.Addr, err error),
|
||||
) (*TCPRedirect, error) {
|
||||
tAddr, err := net.ResolveTCPAddr("tcp", listen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -5,16 +5,18 @@ package redirect
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
)
|
||||
|
||||
type TCPRedirect struct{}
|
||||
|
||||
func NewTCPRedirect(hyClient *core.Client, listen string, timeout time.Duration,
|
||||
connFunc func(addr, reqAddr net.Addr),
|
||||
errorFunc func(addr, reqAddr net.Addr, err error)) (*TCPRedirect, error) {
|
||||
errorFunc func(addr, reqAddr net.Addr, err error),
|
||||
) (*TCPRedirect, error) {
|
||||
return nil, errors.New("not supported on the current system")
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
package relay
|
||||
|
||||
import (
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
)
|
||||
|
||||
type TCPRelay struct {
|
||||
@ -18,7 +19,8 @@ type TCPRelay struct {
|
||||
}
|
||||
|
||||
func NewTCPRelay(hyClient *core.Client, listen, remote string, timeout time.Duration,
|
||||
connFunc func(addr net.Addr), errorFunc func(addr net.Addr, err error)) (*TCPRelay, error) {
|
||||
connFunc func(addr net.Addr), errorFunc func(addr net.Addr, err error),
|
||||
) (*TCPRelay, error) {
|
||||
tAddr, err := net.ResolveTCPAddr("tcp", listen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -2,11 +2,12 @@ package relay
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"net"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
)
|
||||
|
||||
const udpBufferSize = 65535
|
||||
@ -24,7 +25,8 @@ type UDPRelay struct {
|
||||
}
|
||||
|
||||
func NewUDPRelay(hyClient *core.Client, listen, remote string, timeout time.Duration,
|
||||
connFunc func(addr net.Addr), errorFunc func(addr net.Addr, err error)) (*UDPRelay, error) {
|
||||
connFunc func(addr net.Addr), errorFunc func(addr net.Addr, err error),
|
||||
) (*UDPRelay, error) {
|
||||
uAddr, err := net.ResolveUDPAddr("udp", listen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -4,17 +4,19 @@ import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/acl"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"github.com/tobyxdd/hysteria/pkg/transport"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
import (
|
||||
"github.com/txthinking/socks5"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/txthinking/socks5"
|
||||
)
|
||||
|
||||
const udpBufferSize = 65535
|
||||
@ -47,7 +49,8 @@ func NewServer(hyClient *core.Client, transport *transport.ClientTransport, addr
|
||||
aclEngine *acl.Engine, disableUDP bool,
|
||||
tcpReqFunc func(addr net.Addr, reqAddr string, action acl.Action, arg string),
|
||||
tcpErrorFunc func(addr net.Addr, reqAddr string, err error),
|
||||
udpAssocFunc func(addr net.Addr), udpErrorFunc func(addr net.Addr, err error)) (*Server, error) {
|
||||
udpAssocFunc func(addr net.Addr), udpErrorFunc func(addr net.Addr, err error),
|
||||
) (*Server, error) {
|
||||
tAddr, err := net.ResolveTCPAddr("tcp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1,11 +1,12 @@
|
||||
package tproxy
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/LiamHaworth/go-tproxy"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type TCPTProxy struct {
|
||||
@ -19,7 +20,8 @@ type TCPTProxy struct {
|
||||
|
||||
func NewTCPTProxy(hyClient *core.Client, listen string, timeout time.Duration,
|
||||
connFunc func(addr, reqAddr net.Addr),
|
||||
errorFunc func(addr, reqAddr net.Addr, err error)) (*TCPTProxy, error) {
|
||||
errorFunc func(addr, reqAddr net.Addr, err error),
|
||||
) (*TCPTProxy, error) {
|
||||
tAddr, err := net.ResolveTCPAddr("tcp", listen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -5,16 +5,18 @@ package tproxy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
)
|
||||
|
||||
type TCPTProxy struct{}
|
||||
|
||||
func NewTCPTProxy(hyClient *core.Client, listen string, timeout time.Duration,
|
||||
connFunc func(addr, reqAddr net.Addr),
|
||||
errorFunc func(addr, reqAddr net.Addr, err error)) (*TCPTProxy, error) {
|
||||
errorFunc func(addr, reqAddr net.Addr, err error),
|
||||
) (*TCPTProxy, error) {
|
||||
return nil, errors.New("not supported on the current system")
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
package tproxy
|
||||
|
||||
import (
|
||||
"github.com/LiamHaworth/go-tproxy"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/LiamHaworth/go-tproxy"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
)
|
||||
|
||||
const udpBufferSize = 65535
|
||||
@ -20,7 +21,8 @@ type UDPTProxy struct {
|
||||
|
||||
func NewUDPTProxy(hyClient *core.Client, listen string, timeout time.Duration,
|
||||
connFunc func(addr, reqAddr net.Addr),
|
||||
errorFunc func(addr, reqAddr net.Addr, err error)) (*UDPTProxy, error) {
|
||||
errorFunc func(addr, reqAddr net.Addr, err error),
|
||||
) (*UDPTProxy, error) {
|
||||
uAddr, err := net.ResolveUDPAddr("udp", listen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -5,9 +5,10 @@ package tproxy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
)
|
||||
|
||||
var ErrTimeout = errors.New("inactivity timeout")
|
||||
@ -15,7 +16,8 @@ var ErrTimeout = errors.New("inactivity timeout")
|
||||
type UDPTProxy struct{}
|
||||
|
||||
func NewUDPTProxy(hyClient *core.Client, listen string, timeout time.Duration,
|
||||
connFunc func(addr, reqAddr net.Addr), errorFunc func(addr, reqAddr net.Addr, err error)) (*UDPTProxy, error) {
|
||||
connFunc func(addr, reqAddr net.Addr), errorFunc func(addr, reqAddr net.Addr, err error),
|
||||
) (*UDPTProxy, error) {
|
||||
return nil, errors.New("not supported on the current system")
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,14 @@ package transport
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/tobyxdd/hysteria/pkg/conns/faketcp"
|
||||
"github.com/tobyxdd/hysteria/pkg/conns/udp"
|
||||
"github.com/tobyxdd/hysteria/pkg/conns/wechat"
|
||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ClientTransport struct {
|
||||
|
@ -3,6 +3,10 @@ package transport
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/tobyxdd/hysteria/pkg/conns/faketcp"
|
||||
"github.com/tobyxdd/hysteria/pkg/conns/udp"
|
||||
@ -10,9 +14,6 @@ import (
|
||||
"github.com/tobyxdd/hysteria/pkg/obfs"
|
||||
"github.com/tobyxdd/hysteria/pkg/sockopt"
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ServerTransport struct {
|
||||
|
@ -4,9 +4,10 @@ import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/txthinking/socks5"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/txthinking/socks5"
|
||||
)
|
||||
|
||||
type SOCKS5Client struct {
|
||||
|
@ -5,6 +5,13 @@ package tun
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
t2score "github.com/xjasonlyu/tun2socks/v2/core"
|
||||
@ -13,12 +20,6 @@ import (
|
||||
"github.com/xjasonlyu/tun2socks/v2/core/device/fdbased"
|
||||
"github.com/xjasonlyu/tun2socks/v2/core/device/tun"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/stack"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ adapter.TransportHandler = (*Server)(nil)
|
||||
|
@ -4,9 +4,10 @@
|
||||
package tun
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/utils"
|
||||
"github.com/xjasonlyu/tun2socks/v2/core/adapter"
|
||||
"net"
|
||||
)
|
||||
|
||||
func (s *Server) HandleTCP(localConn adapter.TCPConn) {
|
||||
|
@ -5,11 +5,12 @@ package tun
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"github.com/xjasonlyu/tun2socks/v2/core/adapter"
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/tobyxdd/hysteria/pkg/core"
|
||||
"github.com/xjasonlyu/tun2socks/v2/core/adapter"
|
||||
)
|
||||
|
||||
const udpBufferSize = 65535
|
||||
|
Loading…
x
Reference in New Issue
Block a user