Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bad ipversion selection caused by #251 #257

Merged
merged 2 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
"syscall"
"time"

"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/pkg/fastrand"
"github.com/mzz2017/softwind/protocol/direct"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/pkg/fastrand"
"github.com/daeuniverse/softwind/protocol/direct"
"gopkg.in/natefinch/lumberjack.v2"

"github.com/daeuniverse/dae/cmd/internal"
Expand Down
2 changes: 1 addition & 1 deletion common/bitlist/bitlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"math/bits"

"github.com/daeuniverse/dae/pkg/anybuffer"
"github.com/mzz2017/softwind/common"
"github.com/daeuniverse/softwind/common"
)

// CompactBitList allows your units to be of arbitrary bit size.
Expand Down
6 changes: 3 additions & 3 deletions common/netutils/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"time"

"github.com/daeuniverse/dae/common/consts"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/pkg/fastrand"
"github.com/daeuniverse/softwind/pool"
dnsmessage "github.com/miekg/dns"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/pkg/fastrand"
"github.com/mzz2017/softwind/pool"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion common/netutils/ip46.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"net/netip"
"sync"

"github.com/daeuniverse/softwind/netproxy"
dnsmessage "github.com/miekg/dns"
"github.com/mzz2017/softwind/netproxy"
"github.com/sirupsen/logrus"
)

Expand Down
2 changes: 1 addition & 1 deletion common/netutils/ip46_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/mzz2017/softwind/protocol/direct"
"github.com/daeuniverse/softwind/protocol/direct"
)

func TestResolveIp46(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"time"
"unsafe"

"github.com/mzz2017/softwind/netproxy"
"github.com/daeuniverse/softwind/netproxy"

internal "github.com/daeuniverse/dae/pkg/ebpf_internal"
dnsmessage "github.com/miekg/dns"
Expand Down
2 changes: 1 addition & 1 deletion component/dns/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

"github.com/daeuniverse/dae/common/consts"
"github.com/daeuniverse/dae/common/netutils"
"github.com/mzz2017/softwind/protocol/direct"
"github.com/daeuniverse/softwind/protocol/direct"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion component/outbound/dialer/alive_dialer_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"time"

"github.com/daeuniverse/dae/common/consts"
"github.com/mzz2017/softwind/pkg/fastrand"
"github.com/daeuniverse/softwind/pkg/fastrand"
"github.com/sirupsen/logrus"
)

Expand Down
2 changes: 1 addition & 1 deletion component/outbound/dialer/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"net"

"github.com/mzz2017/softwind/netproxy"
"github.com/daeuniverse/softwind/netproxy"
)

type blockDialer struct {
Expand Down
13 changes: 10 additions & 3 deletions component/outbound/dialer/connectivity_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (

"github.com/daeuniverse/dae/common/consts"
"github.com/daeuniverse/dae/common/netutils"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/pkg/fastrand"
"github.com/daeuniverse/softwind/protocol/direct"
dnsmessage "github.com/miekg/dns"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/pkg/fastrand"
"github.com/mzz2017/softwind/protocol/direct"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -96,6 +96,13 @@ func (d *Dialer) mustGetCollection(typ *NetworkType) *collection {
return d.collections[5]
}
case consts.L4ProtoStr_UDP:
// UDP share the DNS check result.
switch typ.IpVersion {
case consts.IpVersionStr_4:
return d.collections[2]
case consts.IpVersionStr_6:
return d.collections[3]
}
}
}
panic("invalid param")
Expand Down
2 changes: 1 addition & 1 deletion component/outbound/dialer/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"time"

"github.com/mzz2017/softwind/netproxy"
"github.com/daeuniverse/softwind/netproxy"
"github.com/sirupsen/logrus"
)

Expand Down
4 changes: 2 additions & 2 deletions component/outbound/dialer/direct.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dialer

import (
"github.com/mzz2017/softwind/netproxy"
softwindDirect "github.com/mzz2017/softwind/protocol/direct"
"github.com/daeuniverse/softwind/netproxy"
softwindDirect "github.com/daeuniverse/softwind/protocol/direct"
)

func NewDirectDialer(option *GlobalOption, fullcone bool) (netproxy.Dialer, *Property) {
Expand Down
4 changes: 2 additions & 2 deletions component/outbound/dialer/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/daeuniverse/dae/common"
"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/protocol/http"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/protocol/http"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions component/outbound/dialer/juicity/juicity.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"github.com/daeuniverse/dae/common"
"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/protocol"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/protocol"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions component/outbound/dialer/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"strings"

"github.com/daeuniverse/dae/common"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/protocol/direct"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/protocol/direct"
)

type FromLinkCreator func(gOption *GlobalOption, nextDialer netproxy.Dialer, link string) (dialer netproxy.Dialer, property *Property, err error)
Expand Down
6 changes: 3 additions & 3 deletions component/outbound/dialer/shadowsocks/shadowsocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"github.com/daeuniverse/dae/common"
"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/daeuniverse/dae/component/outbound/transport/simpleobfs"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/protocol"
"github.com/mzz2017/softwind/protocol/shadowsocks"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/protocol"
"github.com/daeuniverse/softwind/protocol/shadowsocks"
)

func init() {
Expand Down
10 changes: 5 additions & 5 deletions component/outbound/dialer/shadowsocksr/shadowsocksr.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (

"github.com/daeuniverse/dae/common"
"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/protocol"
"github.com/mzz2017/softwind/protocol/shadowsocks_stream"
"github.com/mzz2017/softwind/transport/shadowsocksr/obfs"
"github.com/mzz2017/softwind/transport/shadowsocksr/proto"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/protocol"
"github.com/daeuniverse/softwind/protocol/shadowsocks_stream"
"github.com/daeuniverse/softwind/transport/shadowsocksr/obfs"
"github.com/daeuniverse/softwind/transport/shadowsocksr/proto"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions component/outbound/dialer/socks/socks.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"strconv"

"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/protocol/socks5"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/protocol/socks5"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion component/outbound/dialer/socks/socks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

"github.com/daeuniverse/dae/common/netutils"
"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/daeuniverse/softwind/protocol/direct"
dnsmessage "github.com/miekg/dns"
"github.com/mzz2017/softwind/protocol/direct"
"github.com/sirupsen/logrus"
)

Expand Down
6 changes: 3 additions & 3 deletions component/outbound/dialer/trojan/trojan.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/daeuniverse/dae/common"
"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/daeuniverse/dae/component/outbound/transport/ws"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/protocol"
"github.com/mzz2017/softwind/transport/grpc"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/protocol"
"github.com/daeuniverse/softwind/transport/grpc"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions component/outbound/dialer/tuic/tuic.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/daeuniverse/dae/common"
"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/protocol"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/protocol"
)

func init() {
Expand Down
10 changes: 5 additions & 5 deletions component/outbound/dialer/v2ray/v2ray.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/daeuniverse/dae/component/outbound/transport/tls"
"github.com/daeuniverse/dae/component/outbound/transport/ws"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/protocol"
"github.com/daeuniverse/softwind/protocol/direct"
"github.com/daeuniverse/softwind/protocol/http"
"github.com/daeuniverse/softwind/transport/grpc"
jsoniter "github.com/json-iterator/go"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/protocol"
"github.com/mzz2017/softwind/protocol/direct"
"github.com/mzz2017/softwind/protocol/http"
"github.com/mzz2017/softwind/transport/grpc"
)

func init() {
Expand Down
16 changes: 13 additions & 3 deletions component/outbound/dialer_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/daeuniverse/dae/common/consts"
"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/mzz2017/softwind/netproxy"
"github.com/daeuniverse/softwind/netproxy"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -210,6 +210,13 @@ func (d *DialerGroup) MustGetAliveDialerSet(typ *dialer.NetworkType) *dialer.Ali
return d.aliveDialerSets[5]
}
case consts.L4ProtoStr_UDP:
// UDP share the DNS check result.
switch typ.IpVersion {
case consts.IpVersionStr_4:
return d.aliveDialerSets[2]
case consts.IpVersionStr_6:
return d.aliveDialerSets[3]
}
}
}
panic("invalid param")
Expand All @@ -228,10 +235,13 @@ func (g *DialerGroup) Select(networkType *dialer.NetworkType, strictIpVersion bo
}
if errors.Is(err, NoAliveDialerError) && len(g.Dialers) == 1 {
// There is only one dialer in this group. Just choose it instead of return error.
return g._select(networkType, &DialerSelectionPolicy{
if d, _, err = g._select(networkType, &DialerSelectionPolicy{
Policy: consts.DialerSelectionPolicy_Fixed,
FixedIndex: 0,
})
}); err != nil {
return nil, 0, err
}
return d, dialer.Timeout, nil
}
return nil, latency, err
}
Expand Down
2 changes: 1 addition & 1 deletion component/outbound/dialer_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/daeuniverse/dae/common/consts"
"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/daeuniverse/dae/pkg/logger"
"github.com/mzz2017/softwind/pkg/fastrand"
"github.com/daeuniverse/softwind/pkg/fastrand"
)

const (
Expand Down
12 changes: 6 additions & 6 deletions component/outbound/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
_ "github.com/daeuniverse/dae/component/outbound/transport/simpleobfs"
_ "github.com/daeuniverse/dae/component/outbound/transport/tls"
_ "github.com/daeuniverse/dae/component/outbound/transport/ws"
_ "github.com/mzz2017/softwind/protocol/juicity"
_ "github.com/mzz2017/softwind/protocol/shadowsocks"
_ "github.com/mzz2017/softwind/protocol/trojanc"
_ "github.com/mzz2017/softwind/protocol/tuic"
_ "github.com/mzz2017/softwind/protocol/vless"
_ "github.com/mzz2017/softwind/protocol/vmess"
_ "github.com/daeuniverse/softwind/protocol/juicity"
_ "github.com/daeuniverse/softwind/protocol/shadowsocks"
_ "github.com/daeuniverse/softwind/protocol/trojanc"
_ "github.com/daeuniverse/softwind/protocol/tuic"
_ "github.com/daeuniverse/softwind/protocol/vless"
_ "github.com/daeuniverse/softwind/protocol/vmess"
)
6 changes: 3 additions & 3 deletions component/outbound/transport/simpleobfs/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"bytes"
"encoding/base64"
"fmt"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/pkg/fastrand"
"github.com/mzz2017/softwind/pool"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/pkg/fastrand"
"github.com/daeuniverse/softwind/pool"
"io"
"net/http"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion component/outbound/transport/simpleobfs/simpleobfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/mzz2017/softwind/netproxy"
"github.com/daeuniverse/softwind/netproxy"
)

type ObfsType int
Expand Down
4 changes: 2 additions & 2 deletions component/outbound/transport/simpleobfs/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package simpleobfs
import (
"bytes"
"encoding/binary"
"github.com/mzz2017/softwind/netproxy"
"github.com/mzz2017/softwind/pkg/fastrand"
"github.com/daeuniverse/softwind/netproxy"
"github.com/daeuniverse/softwind/pkg/fastrand"
"io"
"sync"
"time"
Expand Down
2 changes: 1 addition & 1 deletion component/outbound/transport/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"

"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/mzz2017/softwind/netproxy"
"github.com/daeuniverse/softwind/netproxy"
utls "github.com/refraction-networking/utls"
)

Expand Down
2 changes: 1 addition & 1 deletion component/outbound/transport/ws/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"strings"

"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/daeuniverse/softwind/netproxy"
"github.com/gorilla/websocket"
"github.com/mzz2017/softwind/netproxy"
)

// Ws is a base Ws struct
Expand Down
2 changes: 1 addition & 1 deletion component/sniffing/internal/quicutils/cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"crypto/sha256"
"encoding/binary"
"github.com/daeuniverse/dae/common"
"github.com/mzz2017/softwind/pool"
"github.com/daeuniverse/softwind/pool"
"golang.org/x/crypto/hkdf"
"io"
)
Expand Down
2 changes: 1 addition & 1 deletion component/sniffing/internal/quicutils/hkdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package quicutils

import (
"encoding/binary"
"github.com/mzz2017/softwind/pool"
"github.com/daeuniverse/softwind/pool"
"golang.org/x/crypto/hkdf"
"hash"
"io"
Expand Down
Loading