Git Product home page Git Product logo

sing-tun's Introduction

sing-tun

Simple transparent proxy library.

For Linux, Windows, macOS and iOS.

License

Copyright (C) 2022 by nekohasekai <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

sing-tun's People

Contributors

dyhkwong avatar i40e avatar nekohasekai avatar wwqgtxx avatar xyenon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sing-tun's Issues

question: How do the auto-route generated routing rules work?

Hi SagerNet,

I'm a user of the clash.meta project, which depends on your sing-tun project. I'm having some trouble understanding how the auto-route feature works in my configuration. Could you please explain the purpose of the generated routing rules, specifically the rules in the 1970566510 table?

Here's an example of my configuration file:

tun:
  enable: true
  stack: gvisor
  dns-hijack:
    - any:53
  auto-route: true
  auto-detect-interface: true

And here's an example of the generated routing rules:

jo@amd-desktop:~$ ip rule
0:      from all lookup local
9000:   from all to 198.18.0.0/30 lookup 2022
9001:   from all ipproto icmp goto 9010
9002:   not from all dport 53 lookup main suppress_prefixlength 0
9002:   not from all iif lo lookup 2022
9002:   from 0.0.0.0 iif lo lookup 2022
9002:   from 198.18.0.0/30 iif lo lookup 2022
9010:   from all nop
32766:  from all lookup main
32767:  from all lookup default
jo@amd-desktop:$ ip route show table 2022
default dev Meta

Any insights you could provide would be greatly appreciated. Thanks in advance for your help!

with_gvisor构建时在sing-tun上出错

执行编译命令:

go build -tags "with_quic with_grpc with_dhcp with_wireguard with_ech with_utls with_reality_server with_acme with_clash_api with_v2ray_api with_gvisor" -v -trimpath -ldflags "-X 'github.com/sagernet/sing-box/constant.Version=1.8.13' -s -w -buildid=" ./cmd/sing-box

提示:

=" ./cmd/sing-box;8c530658-2ece-4fea-94bb-09ad09070c9agithub.com/sagernet/sing-tun
# github.com/sagernet/sing-tun
C:\Users\moles\go\pkg\mod\github.com\sagernet\[email protected]\stack_gvisor_filter.go:35:104: undefined: stack.PacketBufferPtr       
C:\Users\moles\go\pkg\mod\github.com\sagernet\[email protected]\stack_gvisor_udp.go:45:77: undefined: stack.PacketBufferPtr
C:\Users\moles\go\pkg\mod\github.com\sagernet\[email protected]\stack_gvisor_udp.go:177:58: undefined: stack.PacketBufferPtr
C:\Users\moles\go\pkg\mod\github.com\sagernet\[email protected]\stack_gvisor_udp.go:200:59: undefined: stack.PacketBufferPtr
C:\Users\moles\go\pkg\mod\github.com\sagernet\[email protected]\stack_gvisor_udp.go:208:59: undefined: stack.PacketBufferPtr
C:\Users\moles\go\pkg\mod\github.com\sagernet\[email protected]\tun_windows_gvisor.go:102:49: undefined: stack.PacketBufferPtr        
C:\Users\moles\go\pkg\mod\github.com\sagernet\[email protected]\tun_windows_gvisor.go:105:48: undefined: stack.PacketBufferPtr        
C:\Users\moles\go\pkg\mod\github.com\sagernet\[email protected]\stack_gvisor.go:125:46: too many arguments in call to gonet.NewUDPConn
        have (*stack.Stack, *waiter.Queue, tcpip.Endpoint)
        want (*waiter.Queue, tcpip.Endpoint)
C:\Users\moles\go\pkg\mod\github.com\sagernet\[email protected]\stack_mixed.go:59:46: too many arguments in call to gonet.NewUDPConn  
        have (*stack.Stack, *waiter.Queue, tcpip.Endpoint)
        want (*waiter.Queue, tcpip.Endpoint)

Apple NetworkExtension: `includeAllNetworks` makes `system` TUN stack not work

I can't find on the Internet how includeAllNetworks works, NetworkExtension is really a black box.

Since includeAllNetworks prioritizes TUN routes over DHCP 121 rules, it should work when possible instead of failing silently.

We now refuse to use system (and mixed) stack when includeAllNetworks is enabled.

If you know how to solve this problem, please help us.

Could you please give me some integration suggestions?

Hello!
I wrote a network proxy program. I previously integrated xjasonlu/tun2socks and eycorsican/go-tun2socks by implementing the Dial/DialUDP and HandleTCP/HandleUDP interfaces. Because sing-tun supports system stack, I really want to integrate it to improve the performance of my program. Could you please give me some suggestions? If I want to integrate sing-tun, what interfaces need to be implemented? Thank you very much!

macOS turns off wifi, traffic loopback tun interface

Reproduced

  • sing-box v1.3-beta11
  • clash meta v1.14.4
+0800 2023-05-03 14:42:11 INFO inbound/tun[tun-in]: started at utun3
......
+0800 2023-05-03 14:42:20 INFO router: updated default interface utun3, index 15

Error reading data from Darwin Tun network card while writing to Linux Tun network card

Mac Tun device creation code


	srcPrefix, err := netip.ParsePrefix("10.0.0.1/24")
	if err != nil {
		return nil, err
	}
	dstPrefix, err := netip.ParsePrefix("10.0.0.0/24")
	if err != nil {
		return nil, err
	}

	tun, err := stun.New(stun.Options{
		Name:              "utun3",
		Inet4Address:      []netip.Prefix{srcPrefix},
		MTU:               uint32(1420),
		AutoRoute:         true,
		Inet4RouteAddress: []netip.Prefix{dstPrefix},
	})

Linux Tun device creation code

	srcPrefix, err := netip.ParsePrefix("10.0.0.2/24")
	if err != nil {
		return nil, err
	}
	option := stun.Options{
		Name:         "tun3",
		Inet4Address: []netip.Prefix{srcPrefix},
		MTU:          uint32(1420),
	}
	tun, err := stun.New(option)

I established a tunnel between two machines, but when I forwarded the data packet read from the Mac tun device to the Linux tun device, he encountered this error

write tun: invalid argument

tun causes high cpu usage

Hello,
Using Tun (via NekoRay and VLESS-Reality) along with GoLand causes high cpu usage.

The CPU usage of GoLand goes near to 35% continuously, the GoLand CPU debug shows java.net.http.common using a lot of cpu.
The high cpu usage starts after a while (like 10 minutes) of running goland (start tun before Goland)

You can start Goland without tun and see that there is no high cpu usage.

Tested with GoLand 2023.2.*

Windows 10 32bit error...

windows 10 32bit error...


panic: unaligned 64-bit atomic operation

goroutine 69 [running]:
runtime/internal/atomic.panicUnaligned()
$GOROOT/src/runtime/internal/atomic/unaligned.go:8 +0x2b
runtime/internal/atomic.Load64(0xb0321f4)
$GOROOT/src/runtime/internal/atomic/atomic_386.s:225 +0x10
github.com/sagernet/sing-tun.(*NativeTun).ReadPacket(0xb032120)
pkg/mod/github.com/sagernet/[email protected]/tun_windows.go:341 +0x107
github.com/sagernet/sing-tun.(*Mixed).wintunLoop(0xb091f50, {0x1f50a30, 0xb032120})
pkg/mod/github.com/sagernet/[email protected]/stack_mixed.go:128 +0x27
github.com/sagernet/sing-tun.(*Mixed).tunLoop(0xb091f50)
pkg/mod/github.com/sagernet/[email protected]/stack_mixed.go:91 +0x161
created by github.com/sagernet/sing-tun.(*Mixed).Start in goroutine 1
pkg/mod/github.com/sagernet/[email protected]/stack_mixed.go:84 +0x406

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.