mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Merge protocols
This commit is contained in:
parent
71e10439c8
commit
b172745be0
@ -8,7 +8,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/constant"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -46,7 +46,7 @@ func BitTorrent(_ context.Context, reader io.Reader) (*adapter.InboundContext, e
|
||||
}
|
||||
|
||||
return &adapter.InboundContext{
|
||||
Protocol: constant.ProtocolBitTorrent,
|
||||
Protocol: C.ProtocolBitTorrent,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ func UTP(_ context.Context, packet []byte) (*adapter.InboundContext, error) {
|
||||
}
|
||||
|
||||
return &adapter.InboundContext{
|
||||
Protocol: constant.ProtocolUTP,
|
||||
Protocol: C.ProtocolBitTorrent,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ func UDPTracker(_ context.Context, packet []byte) (*adapter.InboundContext, erro
|
||||
case len(packet) >= trackerScrapeMinSize &&
|
||||
binary.BigEndian.Uint32(packet[8:12]) == trackerScrapeFlag:
|
||||
return &adapter.InboundContext{
|
||||
Protocol: constant.ProtocolUDPTracker,
|
||||
Protocol: C.ProtocolBitTorrent,
|
||||
}, nil
|
||||
default:
|
||||
return nil, os.ErrInvalid
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/sagernet/sing-box/common/sniff"
|
||||
"github.com/sagernet/sing-box/constant"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@ -26,7 +26,7 @@ func TestSniffBittorrent(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
metadata, err := sniff.BitTorrent(context.TODO(), bytes.NewReader(pkt))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, constant.ProtocolBitTorrent, metadata.Protocol)
|
||||
require.Equal(t, C.ProtocolBitTorrent, metadata.Protocol)
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ func TestSniffUTP(t *testing.T) {
|
||||
|
||||
metadata, err := sniff.UTP(context.TODO(), pkt)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, constant.ProtocolUTP, metadata.Protocol)
|
||||
require.Equal(t, C.ProtocolBitTorrent, metadata.Protocol)
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,6 +76,6 @@ func TestSniffUDPTracker(t *testing.T) {
|
||||
|
||||
metadata, err := sniff.UDPTracker(context.TODO(), pkt)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, constant.ProtocolUDPTracker, metadata.Protocol)
|
||||
require.Equal(t, C.ProtocolBitTorrent, metadata.Protocol)
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,4 @@ const (
|
||||
ProtocolDNS = "dns"
|
||||
ProtocolSTUN = "stun"
|
||||
ProtocolBitTorrent = "bittorrent"
|
||||
ProtocolUTP = "utp"
|
||||
ProtocolUDPTracker = "udp-tracker"
|
||||
)
|
||||
|
@ -3,12 +3,10 @@ If enabled in the inbound, the protocol and domain name (if present) of by the c
|
||||
#### Supported Protocols
|
||||
|
||||
| Network | Protocol | Domain Name |
|
||||
| :-----: | :---------: | :---------: |
|
||||
|:-------:|:-----------:|:-----------:|
|
||||
| TCP | HTTP | Host |
|
||||
| TCP | TLS | Server Name |
|
||||
| UDP | QUIC | Server Name |
|
||||
| UDP | STUN | / |
|
||||
| TCP/UDP | DNS | / |
|
||||
| TCP | BitTorrent | / |
|
||||
| UDP | UTP/µTP | / |
|
||||
| UDP | UDP Tracker | / |
|
||||
| TCP/UDP | BitTorrent | / |
|
@ -3,12 +3,10 @@
|
||||
#### 支持的协议
|
||||
|
||||
| 网络 | 协议 | 域名 |
|
||||
| :-----: | :---------: | :---------: |
|
||||
|:-------:|:-----------:|:-----------:|
|
||||
| TCP | HTTP | Host |
|
||||
| TCP | TLS | Server Name |
|
||||
| UDP | QUIC | Server Name |
|
||||
| UDP | STUN | / |
|
||||
| TCP/UDP | DNS | / |
|
||||
| TCP | BitTorrent | / |
|
||||
| UDP | UTP/µTP | / |
|
||||
| UDP | UDP Tracker | / |
|
||||
| TCP/UDP | BitTorrent | / |
|
Loading…
x
Reference in New Issue
Block a user