mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-08-31 06:18:49 +08:00
Compare commits
111 Commits
46bb372a37
...
36c095f660
Author | SHA1 | Date | |
---|---|---|---|
![]() |
36c095f660 | ||
![]() |
71c0ed37b3 | ||
![]() |
860df103b4 | ||
![]() |
d6c9e0349f | ||
![]() |
16e05be1be | ||
![]() |
259a140453 | ||
![]() |
54760eeaaa | ||
![]() |
a870c36d2d | ||
![]() |
1054f58751 | ||
![]() |
6981dfe0c0 | ||
![]() |
719d0d3c31 | ||
![]() |
8f5fad3f9d | ||
![]() |
c2e9c30efc | ||
![]() |
3da06f0db8 | ||
![]() |
acb5065198 | ||
![]() |
c6a7d8c587 | ||
![]() |
a9ff1cbf78 | ||
![]() |
94e0d6b4ab | ||
![]() |
93c866a900 | ||
![]() |
40451f8957 | ||
![]() |
2a2ca1bef6 | ||
![]() |
e156abb0ab | ||
![]() |
94d70a2a97 | ||
![]() |
4b2cda1c76 | ||
![]() |
6e8e007352 | ||
![]() |
d18a35c414 | ||
![]() |
ea31ebb2a3 | ||
![]() |
0951711c08 | ||
![]() |
fdd8d3e23e | ||
![]() |
53feae6a6e | ||
![]() |
b63eba13ef | ||
![]() |
a2c52fb21b | ||
![]() |
01d06c0d29 | ||
![]() |
01b11f3d4e | ||
![]() |
567c98dc9e | ||
![]() |
f8a64a6554 | ||
![]() |
5dd021e979 | ||
![]() |
a3f9196fdc | ||
![]() |
42102b3fc4 | ||
![]() |
c0e5fe78ab | ||
![]() |
ad7bb47bf6 | ||
![]() |
58779f99ce | ||
![]() |
b14782771b | ||
![]() |
51816e0cd2 | ||
![]() |
0b7ea0c6c6 | ||
![]() |
cac33150d8 | ||
![]() |
31bd6bb5cb | ||
![]() |
7f26d21a28 | ||
![]() |
14a8e87e2f | ||
![]() |
38e3766c33 | ||
![]() |
1be391470a | ||
![]() |
560f567881 | ||
![]() |
53dfdd1ec6 | ||
![]() |
69fe3b16f1 | ||
![]() |
85d80deec8 | ||
![]() |
2570b11ea4 | ||
![]() |
d4d1ea7129 | ||
![]() |
5852b5ba94 | ||
![]() |
655674bb9b | ||
![]() |
a55d597212 | ||
![]() |
183aed8253 | ||
![]() |
8f1885bef8 | ||
![]() |
4a13f9828c | ||
![]() |
659b4988ce | ||
![]() |
de1053f2cf | ||
![]() |
f7200c72f2 | ||
![]() |
0febed9b60 | ||
![]() |
ba2ad571d3 | ||
![]() |
36c171aeac | ||
![]() |
76630b474a | ||
![]() |
9a0d4e4ec6 | ||
![]() |
9eaebb970b | ||
![]() |
8f890bcd9a | ||
![]() |
529c0a1e64 | ||
![]() |
00fd52854b | ||
![]() |
043954df8c | ||
![]() |
5acf9344f1 | ||
![]() |
96f96b5b28 | ||
![]() |
2ad59c6bf1 | ||
![]() |
a3bbdaf61e | ||
![]() |
344ee5df43 | ||
![]() |
47c35f5e7a | ||
![]() |
7101407b87 | ||
![]() |
79f84b4333 | ||
![]() |
b9d37ce9f7 | ||
![]() |
e73bb73290 | ||
![]() |
f1623edb5a | ||
![]() |
f42aba5d46 | ||
![]() |
67d934a301 | ||
![]() |
9fbbc0a74e | ||
![]() |
ec0c882efe | ||
![]() |
167a674b8c | ||
![]() |
8df3f470a0 | ||
![]() |
e338c88a5d | ||
![]() |
4b28d626b5 | ||
![]() |
aa9bceecb2 | ||
![]() |
f10bce28a3 | ||
![]() |
7d4f76abea | ||
![]() |
9e27c304b9 | ||
![]() |
b2cb1a39a6 | ||
![]() |
0b790fbabe | ||
![]() |
56e6653c6e | ||
![]() |
5738174060 | ||
![]() |
909893afa9 | ||
![]() |
efdf801332 | ||
![]() |
88fa375f7e | ||
![]() |
f7797e9d34 | ||
![]() |
fb7a7239fd | ||
![]() |
bca97c10a4 | ||
![]() |
7d3ee29bd0 | ||
![]() |
cba0e46aba |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -615,7 +615,7 @@ jobs:
|
|||||||
path: 'dist'
|
path: 'dist'
|
||||||
upload:
|
upload:
|
||||||
name: Upload builds
|
name: Upload builds
|
||||||
if: always() && github.event_name == 'workflow_dispatch' && (inputs.build == 'All' || inputs.build == 'Binary' || inputs.build == 'Android' || inputs.build == 'Apple' || inputs.build == 'macOS-standalone')
|
if: "!failure() && github.event_name == 'workflow_dispatch' && (inputs.build == 'All' || inputs.build == 'Binary' || inputs.build == 'Android' || inputs.build == 'Apple' || inputs.build == 'macOS-standalone')"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
- calculate_version
|
- calculate_version
|
||||||
|
20
Makefile
20
Makefile
@ -108,6 +108,16 @@ upload_ios_app_store:
|
|||||||
cd ../sing-box-for-apple && \
|
cd ../sing-box-for-apple && \
|
||||||
xcodebuild -exportArchive -archivePath build/SFI.xcarchive -exportOptionsPlist SFI/Upload.plist -allowProvisioningUpdates
|
xcodebuild -exportArchive -archivePath build/SFI.xcarchive -exportOptionsPlist SFI/Upload.plist -allowProvisioningUpdates
|
||||||
|
|
||||||
|
export_ios_ipa:
|
||||||
|
cd ../sing-box-for-apple && \
|
||||||
|
xcodebuild -exportArchive -archivePath build/SFI.xcarchive -exportOptionsPlist SFI/Export.plist -allowProvisioningUpdates -exportPath build/SFI && \
|
||||||
|
cp build/SFI/sing-box.ipa dist/SFI.ipa
|
||||||
|
|
||||||
|
upload_ios_ipa:
|
||||||
|
cd dist && \
|
||||||
|
cp SFI.ipa "SFI-${VERSION}.ipa" && \
|
||||||
|
ghr --replace --draft --prerelease "v${VERSION}" "SFI-${VERSION}.ipa"
|
||||||
|
|
||||||
release_ios: build_ios upload_ios_app_store
|
release_ios: build_ios upload_ios_app_store
|
||||||
|
|
||||||
build_macos:
|
build_macos:
|
||||||
@ -175,6 +185,16 @@ upload_tvos_app_store:
|
|||||||
cd ../sing-box-for-apple && \
|
cd ../sing-box-for-apple && \
|
||||||
xcodebuild -exportArchive -archivePath "build/SFT.xcarchive" -exportOptionsPlist SFI/Upload.plist -allowProvisioningUpdates
|
xcodebuild -exportArchive -archivePath "build/SFT.xcarchive" -exportOptionsPlist SFI/Upload.plist -allowProvisioningUpdates
|
||||||
|
|
||||||
|
export_tvos_ipa:
|
||||||
|
cd ../sing-box-for-apple && \
|
||||||
|
xcodebuild -exportArchive -archivePath "build/SFT.xcarchive" -exportOptionsPlist SFI/Export.plist -allowProvisioningUpdates -exportPath build/SFT && \
|
||||||
|
cp build/SFT/sing-box.ipa dist/SFT.ipa
|
||||||
|
|
||||||
|
upload_tvos_ipa:
|
||||||
|
cd dist && \
|
||||||
|
cp SFT.ipa "SFT-${VERSION}.ipa" && \
|
||||||
|
ghr --replace --draft --prerelease "v${VERSION}" "SFT-${VERSION}.ipa"
|
||||||
|
|
||||||
release_tvos: build_tvos upload_tvos_app_store
|
release_tvos: build_tvos upload_tvos_app_store
|
||||||
|
|
||||||
update_apple_version:
|
update_apple_version:
|
||||||
|
@ -53,11 +53,11 @@ type InboundContext struct {
|
|||||||
|
|
||||||
// sniffer
|
// sniffer
|
||||||
|
|
||||||
Protocol string
|
Protocol string
|
||||||
Domain string
|
Domain string
|
||||||
Client string
|
Client string
|
||||||
SniffContext any
|
SniffContext any
|
||||||
PacketSniffError error
|
SniffError error
|
||||||
|
|
||||||
// cache
|
// cache
|
||||||
|
|
||||||
|
@ -16,15 +16,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
debugEnabled bool
|
debugEnabled bool
|
||||||
target string
|
target string
|
||||||
platform string
|
platform string
|
||||||
|
withTailscale bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.BoolVar(&debugEnabled, "debug", false, "enable debug")
|
flag.BoolVar(&debugEnabled, "debug", false, "enable debug")
|
||||||
flag.StringVar(&target, "target", "android", "target platform")
|
flag.StringVar(&target, "target", "android", "target platform")
|
||||||
flag.StringVar(&platform, "platform", "", "specify platform")
|
flag.StringVar(&platform, "platform", "", "specify platform")
|
||||||
|
flag.BoolVar(&withTailscale, "tailscale", false, "build tailscale for iOS and tvOS")
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -151,7 +153,9 @@ func buildApple() {
|
|||||||
"-v",
|
"-v",
|
||||||
"-target", bindTarget,
|
"-target", bindTarget,
|
||||||
"-libname=box",
|
"-libname=box",
|
||||||
"-tags-macos=" + strings.Join(memcTags, ","),
|
}
|
||||||
|
if withTailscale {
|
||||||
|
args = append(args, "-tags-macos="+strings.Join(memcTags, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !debugEnabled {
|
if !debugEnabled {
|
||||||
@ -161,6 +165,9 @@ func buildApple() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tags := append(sharedTags, iosTags...)
|
tags := append(sharedTags, iosTags...)
|
||||||
|
if withTailscale {
|
||||||
|
tags = append(tags, memcTags...)
|
||||||
|
}
|
||||||
if debugEnabled {
|
if debugEnabled {
|
||||||
tags = append(tags, debugTags...)
|
tags = append(tags, debugTags...)
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ parseLine:
|
|||||||
}
|
}
|
||||||
if !ignored {
|
if !ignored {
|
||||||
ignoredLines++
|
ignoredLines++
|
||||||
logger.Debug("ignored unsupported rule with modifier: ", paramParts[0], ": ", ruleLine)
|
logger.Debug("ignored unsupported rule with modifier: ", paramParts[0], ": ", originRuleLine)
|
||||||
continue parseLine
|
continue parseLine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,34 +124,35 @@ parseLine:
|
|||||||
ruleLine = ruleLine[1 : len(ruleLine)-1]
|
ruleLine = ruleLine[1 : len(ruleLine)-1]
|
||||||
if ignoreIPCIDRRegexp(ruleLine) {
|
if ignoreIPCIDRRegexp(ruleLine) {
|
||||||
ignoredLines++
|
ignoredLines++
|
||||||
logger.Debug("ignored unsupported rule with IPCIDR regexp: ", ruleLine)
|
logger.Debug("ignored unsupported rule with IPCIDR regexp: ", originRuleLine)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
isRegexp = true
|
isRegexp = true
|
||||||
} else {
|
} else {
|
||||||
if strings.Contains(ruleLine, "://") {
|
if strings.Contains(ruleLine, "://") {
|
||||||
ruleLine = common.SubstringAfter(ruleLine, "://")
|
ruleLine = common.SubstringAfter(ruleLine, "://")
|
||||||
|
isSuffix = true
|
||||||
}
|
}
|
||||||
if strings.Contains(ruleLine, "/") {
|
if strings.Contains(ruleLine, "/") {
|
||||||
ignoredLines++
|
ignoredLines++
|
||||||
logger.Debug("ignored unsupported rule with path: ", ruleLine)
|
logger.Debug("ignored unsupported rule with path: ", originRuleLine)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.Contains(ruleLine, "?") || strings.Contains(ruleLine, "&") {
|
if strings.Contains(ruleLine, "?") || strings.Contains(ruleLine, "&") {
|
||||||
ignoredLines++
|
ignoredLines++
|
||||||
logger.Debug("ignored unsupported rule with query: ", ruleLine)
|
logger.Debug("ignored unsupported rule with query: ", originRuleLine)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.Contains(ruleLine, "[") || strings.Contains(ruleLine, "]") ||
|
if strings.Contains(ruleLine, "[") || strings.Contains(ruleLine, "]") ||
|
||||||
strings.Contains(ruleLine, "(") || strings.Contains(ruleLine, ")") ||
|
strings.Contains(ruleLine, "(") || strings.Contains(ruleLine, ")") ||
|
||||||
strings.Contains(ruleLine, "!") || strings.Contains(ruleLine, "#") {
|
strings.Contains(ruleLine, "!") || strings.Contains(ruleLine, "#") {
|
||||||
ignoredLines++
|
ignoredLines++
|
||||||
logger.Debug("ignored unsupported cosmetic filter: ", ruleLine)
|
logger.Debug("ignored unsupported cosmetic filter: ", originRuleLine)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.Contains(ruleLine, "~") {
|
if strings.Contains(ruleLine, "~") {
|
||||||
ignoredLines++
|
ignoredLines++
|
||||||
logger.Debug("ignored unsupported rule modifier: ", ruleLine)
|
logger.Debug("ignored unsupported rule modifier: ", originRuleLine)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var domainCheck string
|
var domainCheck string
|
||||||
@ -170,13 +171,13 @@ parseLine:
|
|||||||
_, ipErr := parseADGuardIPCIDRLine(ruleLine)
|
_, ipErr := parseADGuardIPCIDRLine(ruleLine)
|
||||||
if ipErr == nil {
|
if ipErr == nil {
|
||||||
ignoredLines++
|
ignoredLines++
|
||||||
logger.Debug("ignored unsupported rule with IPCIDR: ", ruleLine)
|
logger.Debug("ignored unsupported rule with IPCIDR: ", originRuleLine)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if M.ParseSocksaddr(domainCheck).Port != 0 {
|
if M.ParseSocksaddr(domainCheck).Port != 0 {
|
||||||
logger.Debug("ignored unsupported rule with port: ", ruleLine)
|
logger.Debug("ignored unsupported rule with port: ", originRuleLine)
|
||||||
} else {
|
} else {
|
||||||
logger.Debug("ignored unsupported rule with invalid domain: ", ruleLine)
|
logger.Debug("ignored unsupported rule with invalid domain: ", originRuleLine)
|
||||||
}
|
}
|
||||||
ignoredLines++
|
ignoredLines++
|
||||||
continue
|
continue
|
||||||
@ -407,11 +408,9 @@ func ignoreIPCIDRRegexp(ruleLine string) bool {
|
|||||||
ruleLine = ruleLine[13:]
|
ruleLine = ruleLine[13:]
|
||||||
} else if strings.HasPrefix(ruleLine, "^") {
|
} else if strings.HasPrefix(ruleLine, "^") {
|
||||||
ruleLine = ruleLine[1:]
|
ruleLine = ruleLine[1:]
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
_, parseErr := strconv.ParseUint(common.SubstringBefore(ruleLine, "\\."), 10, 8)
|
return common.Error(strconv.ParseUint(common.SubstringBefore(ruleLine, "\\."), 10, 8)) == nil ||
|
||||||
return parseErr == nil
|
common.Error(strconv.ParseUint(common.SubstringBefore(ruleLine, "."), 10, 8)) == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseAdGuardHostLine(ruleLine string) (string, error) {
|
func parseAdGuardHostLine(ruleLine string) (string, error) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
icon: material/alert-decagram
|
icon: material/alert-decagram
|
||||||
---
|
---
|
||||||
|
|
||||||
#### 1.12.0-beta.27
|
#### 1.12.0-beta.28
|
||||||
|
|
||||||
* Fixes and improvements
|
* Fixes and improvements
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ icon: material/new-box
|
|||||||
"auto_redirect_input_mark": "0x2023",
|
"auto_redirect_input_mark": "0x2023",
|
||||||
"auto_redirect_output_mark": "0x2024",
|
"auto_redirect_output_mark": "0x2024",
|
||||||
"loopback_address": [
|
"loopback_address": [
|
||||||
"10.0.7.1"
|
"10.7.0.1"
|
||||||
],
|
],
|
||||||
"strict_route": true,
|
"strict_route": true,
|
||||||
"route_address": [
|
"route_address": [
|
||||||
@ -284,7 +284,7 @@ Connection output mark used by `auto_redirect`.
|
|||||||
|
|
||||||
Loopback addresses make TCP connections to the specified address connect to the source address.
|
Loopback addresses make TCP connections to the specified address connect to the source address.
|
||||||
|
|
||||||
Setting option value to `10.0.7.1` achieves the same behavior as SideStore/StosVPN.
|
Setting option value to `10.7.0.1` achieves the same behavior as SideStore/StosVPN.
|
||||||
|
|
||||||
When `auto_redirect` is enabled, the same behavior can be achieved for LAN devices (not just local) as a gateway.
|
When `auto_redirect` is enabled, the same behavior can be achieved for LAN devices (not just local) as a gateway.
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ icon: material/new-box
|
|||||||
"auto_redirect_input_mark": "0x2023",
|
"auto_redirect_input_mark": "0x2023",
|
||||||
"auto_redirect_output_mark": "0x2024",
|
"auto_redirect_output_mark": "0x2024",
|
||||||
"loopback_address": [
|
"loopback_address": [
|
||||||
"10.0.7.1"
|
"10.7.0.1"
|
||||||
],
|
],
|
||||||
"strict_route": true,
|
"strict_route": true,
|
||||||
"route_address": [
|
"route_address": [
|
||||||
@ -283,7 +283,7 @@ tun 接口的 IPv6 前缀。
|
|||||||
|
|
||||||
环回地址是用于使指向指定地址的 TCP 连接连接到来源地址的。
|
环回地址是用于使指向指定地址的 TCP 连接连接到来源地址的。
|
||||||
|
|
||||||
将选项值设置为 `10.0.7.1` 可实现与 SideStore/StosVPN 相同的行为。
|
将选项值设置为 `10.7.0.1` 可实现与 SideStore/StosVPN 相同的行为。
|
||||||
|
|
||||||
当启用 `auto_redirect` 时,可以作为网关为局域网设备(而不仅仅是本地)实现相同的行为。
|
当启用 `auto_redirect` 时,可以作为网关为局域网设备(而不仅仅是本地)实现相同的行为。
|
||||||
|
|
||||||
|
@ -501,6 +501,9 @@ func (r *Router) actionSniff(
|
|||||||
if inputConn != nil {
|
if inputConn != nil {
|
||||||
if len(action.StreamSniffers) == 0 && len(action.PacketSniffers) > 0 {
|
if len(action.StreamSniffers) == 0 && len(action.PacketSniffers) > 0 {
|
||||||
return
|
return
|
||||||
|
} else if metadata.SniffError != nil && !errors.Is(metadata.SniffError, sniff.ErrNeedMoreData) {
|
||||||
|
r.logger.DebugContext(ctx, "packet sniff skipped due to previous error: ", metadata.SniffError)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
var streamSniffers []sniff.StreamSniffer
|
var streamSniffers []sniff.StreamSniffer
|
||||||
if len(action.StreamSniffers) > 0 {
|
if len(action.StreamSniffers) > 0 {
|
||||||
@ -525,6 +528,7 @@ func (r *Router) actionSniff(
|
|||||||
action.Timeout,
|
action.Timeout,
|
||||||
streamSniffers...,
|
streamSniffers...,
|
||||||
)
|
)
|
||||||
|
metadata.SniffError = err
|
||||||
if err == nil {
|
if err == nil {
|
||||||
//goland:noinspection GoDeprecation
|
//goland:noinspection GoDeprecation
|
||||||
if action.OverrideDestination && M.IsDomainName(metadata.Domain) {
|
if action.OverrideDestination && M.IsDomainName(metadata.Domain) {
|
||||||
@ -549,8 +553,8 @@ func (r *Router) actionSniff(
|
|||||||
} else if inputPacketConn != nil {
|
} else if inputPacketConn != nil {
|
||||||
if len(action.PacketSniffers) == 0 && len(action.StreamSniffers) > 0 {
|
if len(action.PacketSniffers) == 0 && len(action.StreamSniffers) > 0 {
|
||||||
return
|
return
|
||||||
} else if metadata.PacketSniffError != nil && !errors.Is(metadata.PacketSniffError, sniff.ErrNeedMoreData) {
|
} else if metadata.SniffError != nil && !errors.Is(metadata.SniffError, sniff.ErrNeedMoreData) {
|
||||||
r.logger.DebugContext(ctx, "packet sniff skipped due to previous error: ", metadata.PacketSniffError)
|
r.logger.DebugContext(ctx, "packet sniff skipped due to previous error: ", metadata.SniffError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var packetSniffers []sniff.PacketSniffer
|
var packetSniffers []sniff.PacketSniffer
|
||||||
@ -598,7 +602,7 @@ func (r *Router) actionSniff(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(packetBuffers) > 0 || metadata.PacketSniffError != nil {
|
if len(packetBuffers) > 0 || metadata.SniffError != nil {
|
||||||
err = sniff.PeekPacket(
|
err = sniff.PeekPacket(
|
||||||
ctx,
|
ctx,
|
||||||
metadata,
|
metadata,
|
||||||
@ -618,7 +622,7 @@ func (r *Router) actionSniff(
|
|||||||
Destination: destination,
|
Destination: destination,
|
||||||
}
|
}
|
||||||
packetBuffers = append(packetBuffers, packetBuffer)
|
packetBuffers = append(packetBuffers, packetBuffer)
|
||||||
metadata.PacketSniffError = err
|
metadata.SniffError = err
|
||||||
if errors.Is(err, sniff.ErrNeedMoreData) {
|
if errors.Is(err, sniff.ErrNeedMoreData) {
|
||||||
// TODO: replace with generic message when there are more multi-packet protocols
|
// TODO: replace with generic message when there are more multi-packet protocols
|
||||||
r.logger.DebugContext(ctx, "attempt to sniff fragmented QUIC client hello")
|
r.logger.DebugContext(ctx, "attempt to sniff fragmented QUIC client hello")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user