Giter VIP home page Giter VIP logo

badvpn's Introduction

This repository has been archived and is not being maintained by the author any longer.

BadVPN

Introduction

In this project I host some of my open-source networking software. All of the software is written in C and utilizes a custom-developed framework for event-driven programming. The extensive code sharing is the reason all the software is packaged together. However, it is possible to compile only the required components to avoid extra dependencies.

NCD programming language

NCD (Network Configuration Daemon) is a daemon and programming/scripting language for configuration of network interfaces and other aspects of the operating system. It implements various functionalities as built-in modules, which may be used from an NCD program wherever and for whatever purpose the user needs them. This modularity makes NCD extremely flexible and extensible. It does a very good job with hotplugging in various forms, like USB network interfaces and link detection for wired devices. New features can be added by implementing statements as C-language modules using a straightforward interface.

Tun2socks network-layer proxifier

The tun2socks program "socksifes" TCP connections at the network layer. It implements a TUN device which accepts all incoming TCP connections (regardless of destination IP), and forwards the connections through a SOCKS server. This allows you to forward all connections through SOCKS, without any need for application support. It can be used, for example, to forward connections through a remote SSH server.

Peer-to-peer VPN

The VPN part of this project implements a Layer 2 (Ethernet) network between the peers (VPN nodes). The peers connect to a central server which acts as a communication proxy allowing the peers to establish direct connections between each other (data connections). These connections are used for transferring network data (Ethernet frames), and can be secured with a multitude of mechanisms. Notable features are:

  • UDP and TCP transport
  • Converges very quickly after a new peer joins
  • IGMP snooping to deliver multicasts efficiently (e.g. for IPTV)
  • Double SSL: if SSL is enabled, not only do peers connect to the server with SSL, but they use an additional layer of SSL when exchanging messages through the server
  • Features related to the NAT problem:
    • Can work with multiple layers of NAT (needs configuration)
    • Local peers inside a NAT can communicate directly
    • Relaying as a fallback (needs configuration)

Requirements

NCD only works on Linux. Tun2socks works on Linux and Windows. The P2P VPN works on Linux, Windows and FreeBSD (not tested often).

Installation

The build system is based on CMake. On Linux, the following commands can be used to build:

cd <badvpn-source-dir>
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=<install-dir>
make install

If you only need tun2socks or udpgw, then add the following arguments to the cmake command: -DBUILD_NOTHING_BY_DEFAULT=1 -DBUILD_TUN2SOCKS=1 -DBUILD_UDPGW=1. Otherwise (if you want the VPN software), you will first need to install the OpenSSL and NSS libraries and make sure that CMake can find them.

Windows builds are not provided. You can build from source code using Visual Studio by following the instructions in the file BUILD-WINDOWS-VisualStudio.md.

License

The BSD 3-clause license as shown below applies to most of the code.

Copyright (c) 2009, Ambroz Bizjak <[email protected]>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. Neither the name of the author nor the
   names of its contributors may be used to endorse or promote products
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

List of third-party code included in the source:

  • lwIP - A Lightweight TCP/IP stack. License: lwip/COPYING

badvpn's People

Contributors

abryantsev avatar ambrop72 avatar felixonmars avatar hasufell avatar hexchain avatar mygod avatar perpetual-hydrofoil avatar tsln1998 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  avatar

Watchers

 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  avatar

badvpn's Issues

Cannot compile on Linux

I'd download the latest source and tried to compile tun2socks, but finally it throws me a error:

|-------------- Terminal output ------------------|
<0> [anthony@ZONGYI-NOTEBOOK /home/blocker/workingdir/download_source] $ git clone https://github.com/ambrop72/badvpn
Cloning into 'badvpn'...
remote: Counting objects: 14479, done.
remote: Total 14479 (delta 0), reused 0 (delta 0), pack-reused 14479
Receiving objects: 100% (14479/14479), 4.74 MiB | 674.00 KiB/s, done.
Resolving deltas: 100% (11113/11113), done.
<0> [anthony@ZONGYI-NOTEBOOK /home/blocker/workingdir/download_source] $ cd badvpn/
<0> [anthony@ZONGYI-NOTEBOOK /home/blocker/workingdir/download_source/badvpn] $ mkdir build
<0> [anthony@ZONGYI-NOTEBOOK /home/blocker/workingdir/download_source/badvpn] $ cd build
<0> [anthony@ZONGYI-NOTEBOOK /home/blocker/workingdir/download_source/badvpn/build] $ ENDIAN=little CC=gcc SRCDIR=../ ../compile-tun2sock.sh

/* Omitting compile output */

  • OBJS=("${OBJS[@]}" "${obj}")
  • gcc BLog_syslog.c.o BReactor_badvpn.c.o BSignal.c.o BConnection_unix.c.o BConnection_common.c.o BTime.c.o BUnixSignal.c.o BNetwork.c.o BDatagram_unix.c.o StreamRecvInterface.c.o PacketRecvInterface.c.o PacketPassInterface.c.o StreamPassInterface.c.o SinglePacketBuffer.c.o BufferWriter.c.o PacketBuffer.c.o PacketStreamSender.c.o PacketPassConnector.c.o PacketProtoFlow.c.o PacketPassFairQueue.c.o PacketProtoEncoder.c.o PacketProtoDecoder.c.o BSocksClient.c.o BTap.c.o timers.c.o udp.c.o memp.c.o init.c.o pbuf.c.o tcp.c.o tcp_out.c.o netif.c.o def.c.o mem.c.o tcp_in.c.o stats.c.o inet_chksum.c.o icmp.c.o ip4.c.o ip4_addr.c.o ip_frag.c.o ip6.c.o nd6.c.o icmp6.c.o ip6_addr.c.o ip6_frag.c.o sys.c.o tun2socks.c.o DebugObject.c.o BLog.c.o BPending.c.o PacketPassInactivityMonitor.c.o SocksUdpGwClient.c.o UdpGwClient.c.o -o ./tun2socks -lrt
    /usr/bin/ld: BUnixSignal.c.o: undefined reference to symbol 'pthread_sigmask@@GLIBC_2.2.5'
    //lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status
    <1> [anthony@ZONGYI-NOTEBOOK /home/blocker/workingdir/download_source/badvpn/build] $
    |------------- Cut here ----------------------|

Maybe something troubled with my ld. here is my system information:

|-------------- Terminal output ---------------|
<0> [anthony@ZONGYI-NOTEBOOK /home/blocker/workingdir/download_source/badvpn/build] $ gcc --version
gcc (Debian 6.3.0-18) 6.3.0 20170516
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

<0> [anthony@ZONGYI-NOTEBOOK /home/blocker/workingdir/download_source/badvpn/build] $ ld -V
GNU ld (GNU Binutils for Debian) 2.28
Supported emulations:
elf_x86_64
elf32_x86_64
elf_i386
elf_iamcu
i386linux
elf_l1om
elf_k1om
i386pep
i386pe
<0> [anthony@ZONGYI-NOTEBOOK /home/blocker/workingdir/download_source/badvpn/build] $ uname -a
Linux ZONGYI-NOTEBOOK 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64 GNU/Linux
<0> [anthony@ZONGYI-NOTEBOOK /home/blocker/workingdir/download_source/badvpn/build] $
|------------ Cut here ---------------|

Hope for fix.

TUN device issues (Windows 8.1)

Again, apologies if this is a a very specific question, but I'm having trouble getting the Tun2Socks part of this project to work on Windows 8.1 because of some problem with the TAP/TUN drivers (or more specifically the communications that take place between the driver and Tun2Socks). Currently I'm using OpenVPN's 'Add a new TAP virtual ethernet adapter' function, which creates a device 'tap0901'. This works out just fine (when run with Adminstrative priveleges), and OpenVPN seems to be able to use it fine as well. The problem occurs when I try to pass on the device to Tun2Socks, where upon running the command: badvpn-tun2socks.exe --tundev tap0901 --netif-ipaddr 127.0.0.1 --netif-netmask 255.255.255.0 --socks-server-addr SOMEADDRESS:80 I get the following output:


NOTICE(tun2socks): initializing BadVPN tun2socks 1.999.130
DEBUG(BReactor): Reactor initializing
DEBUG(BSignal): BSignal initializing
split_spec: missing separator number 1
ERROR(BTap): failed to parse TUN device specification
ERROR(tun2socks): BTap_Init failed
DEBUG(BReactor): Reactor freeing
NOTICE(tun2socks): exiting

I have tried running in Admin mode, using different identifiers (device name, device display name, friendly name, in fact almost every single property visible in the device manager). I would love to hear some help from you regarding this, as I depend a lot on this tool, which has no replacement and which I'd love to help out on once I'm finished with my particular project.

Building with shared libraries

I don't know if building with shared libraries is even supposed to be supported...

My build command:

cmake ../${_realname}-${pkgver} \
    -G "MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX="${pkgdir}${MINGW_PREFIX}" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INCLUDE_PATH="${MINGW_PREFIX}"/include/nspr:"${MINGW_PREFIX}"/include/nss3 \
    -DBUILD_EXAMPLES=OFF \
    -DBUILD_TESTS=OFF \
    -DBUILD_SHARED_LIBS=ON
  make

First error:

cd /W/temporary/development/mingw-packages/mingw-w64-badvpn/src/build-x86_64/lwip && /D/applications/msys2.x64/mingw64/bin/gcc.exe    -pipe -shared -o liblwip.dll -Wl,--out-implib,liblwip.dll.a -Wl,--major-image-version,0,--minor-image-version,0 "CMakeFiles/lwip.dir/src/core/timers.c.obj" "CMakeFiles/lwip.dir/src/core/udp.c.obj" "CMakeFiles/lwip.dir/src/core/memp.c.obj" "CMakeFiles/lwip.dir/src/core/init.c.obj" "CMakeFiles/lwip.dir/src/core/pbuf.c.obj" "CMakeFiles/lwip.dir/src/core/tcp.c.obj" "CMakeFiles/lwip.dir/src/core/tcp_out.c.obj" "CMakeFiles/lwip.dir/src/core/sys.c.obj" "CMakeFiles/lwip.dir/src/core/netif.c.obj" "CMakeFiles/lwip.dir/src/core/def.c.obj" "CMakeFiles/lwip.dir/src/core/mem.c.obj" "CMakeFiles/lwip.dir/src/core/tcp_in.c.obj" "CMakeFiles/lwip.dir/src/core/stats.c.obj" "CMakeFiles/lwip.dir/src/core/inet_chksum.c.obj" "CMakeFiles/lwip.dir/src/core/ipv4/icmp.c.obj" "CMakeFiles/lwip.dir/src/core/ipv4/ip4.c.obj" "CMakeFiles/lwip.dir/src/core/ipv4/ip4_addr.c.obj" "CMakeFiles/lwip.dir/src/core/ipv4/ip_frag.c.obj" "CMakeFiles/lwip.dir/src/core/ipv6/ip6.c.obj" "CMakeFiles/lwip.dir/src/core/ipv6/nd6.c.obj" "CMakeFiles/lwip.dir/src/core/ipv6/icmp6.c.obj" "CMakeFiles/lwip.dir/src/core/ipv6/ip6_addr.c.obj" "CMakeFiles/lwip.dir/src/core/ipv6/ip6_frag.c.obj" "CMakeFiles/lwip.dir/custom/sys.c.obj"  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
CMakeFiles/lwip.dir/custom/sys.c.obj:sys.c:(.rdata$.refptr.btime_global[.refptr.btime_global]+0x0): undefined reference to `btime_global'
collect2.exe: error: ld returned 1 exit status
lwip/CMakeFiles/lwip.dir/build.make:659: recipe for target 'lwip/liblwip.dll' failed

If I add ../system/CMakeFiles/system.dir/BTime.c.obj to the gcc command, liblwip.dll compiles, but then I get a second error:

cd /W/temporary/development/mingw-packages/mingw-w64-badvpn/src/build-x86_64/server && /D/applications/msys2.x64/mingw64/bin/gcc.exe  -march=x86-64 -mtune=generic -O2 -pipe  -O3 -DNDEBUG   -pipe "CMakeFiles/badvpn-server.dir/server.c.obj"   -o badvpn-server.exe -Wl,--out-implib,libbadvpn-server.dll.a -Wl,--major-image-version,0,--minor-image-version,0  ../system/libsystem.a ../flow/libflow.a ../flowextra/libflowextra.dll.a ../nspr_support/libnspr_support.dll.a ../predicate/libpredicate.dll.a ../security/libsecurity.dll.a /D/applications/msys2.x64/mingw64/bin/libplds4.dll /D/applications/msys2.x64/mingw64/bin/libplc4.dll /D/applications/msys2.x64/mingw64/bin/libnspr4.dll /D/applications/msys2.x64/mingw64/bin/ssl3.dll /D/applications/msys2.x64/mingw64/bin/smime3.dll /D/applications/msys2.x64/mingw64/bin/nss3.dll ../threadwork/libthreadwork.dll.a ../system/libsystem.a ../flow/libflow.a ../base/libbase.a -lws2_32 -lmswsock -lssl -lcrypto -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
../base/libbase.a(BLog.c.obj):BLog.c:(.text+0xd0): multiple definition of `BLog_InitStdout'
../flowextra/libflowextra.dll.a(d000002.o):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
server/CMakeFiles/badvpn-server.dir/build.make:102: recipe for target 'server/badvpn-server.exe' failed

Any suggestions?

tun2socks Process Won't Quit

The Systemd Unit I made for tun2socks always fails to stop.

Output of systemctl status

$ sudo systemctl status tun2socks.service 
● tun2socks.service - RSG Tunnel: tun2socks Service
   Loaded: loaded (/etc/systemd/system/tun2socks.service; enabled; vendor preset: enabled)
   Active: failed (Result: signal) since Tue 2015-05-05 15:01:47 CST; 53s ago
 Main PID: 2317 (code=killed, signal=KILL)

...
May 05 15:01:46 folio systemd[1]: Unit tun2socks.service is not needed anymore. Stopping.
May 05 15:01:46 folio systemd[1]: Stopping RSG Tunnel: tun2socks Service...
May 05 15:01:47 folio systemd[1]: tun2socks.service stop-sigterm timed out. Killing.
May 05 15:01:47 folio systemd[1]: tun2socks.service: main process exited, code=killed, status=9/KILL
May 05 15:01:47 folio systemd[1]: Stopped RSG Tunnel: tun2socks Service.
May 05 15:01:47 folio systemd[1]: Unit tun2socks.service entered failed state.
May 05 15:01:47 folio systemd[1]: tun2socks.service failed.

Version of badvpn

$ apt-cache show badvpn 
Package: badvpn
Priority: extra
Section: net
Installed-Size: 1381
Maintainer: Ambroz Bizjak <[email protected]>
Architecture: amd64
Version: 1.999.129-1~trusty1
Depends: libc6 (>= 2.14), libnspr4 (>= 2:4.9-2~) | libnspr4-0d (>= 1.8.0.10), libnss3 (>= 2:3.13.4-2~) | libnss3-1d (>= 3.12.0~1.9b1), libssl1.0.0 (>= 1.0.0), sysv-rc (>= 2.88dsf-24) | file-rc (>= 0.8.16)
Filename: pool/main/b/badvpn/badvpn_1.999.129-1~trusty1_amd64.deb
Size: 381748
MD5sum: 4ee69759f9ccfdee48ac9bf2ac9ec178
SHA1: 7d16c1a6d89923e1d75269135b4e8284bea61fe7
SHA256: 08ba4e88f7f482f4e3ec78cf5650288e27da784976b90268d78d8a9cd2ea8d9d
Description: Peer-to-peer VPN and NCD, the Network Configuration Daemon
 BadVPN in a Layer 2 peer-to-peer VPN software.
 Also contains NCD, Network Configuration Daemon, a powerful system
 for network configurations that is really a programming language.
Description-md5: 2cc554d5a2dd72714803d4d6ead37408

Version of Kernel

$ apt-cache show linux-image-generic 
Package: linux-image-generic
Priority: optional
Section: kernel
Installed-Size: 27
Maintainer: Ubuntu Kernel Team <[email protected]>
Architecture: amd64
Source: linux-meta
Version: 3.19.0.15.14
Depends: linux-image-3.19.0-15-generic, linux-image-extra-3.19.0-15-generic, linux-firmware
Recommends: thermald
Filename: pool/main/l/linux-meta/linux-image-generic_3.19.0.15.14_amd64.deb
Size: 2416
MD5sum: e0738e1b7be25935f551df9831f40770
SHA1: d07ad5a841c54c728a406e4b31744dafb3eefd8a
SHA256: 67b8734f1352152529535afe8ead562d592308d892e1535176c165e07a95012c
Description-en: Generic Linux kernel image
 This package will always depend on the latest generic kernel image
 available.
Description-md5: 6d632579c673704f44b290b16e7dbfd1
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 9m

Please help me set the correct route for raspberry pi

I have a raspberry pi 3 that I plan to use as a wifi hotspot. All works fine and all I need is just to get badvpn-tun2socks work on my pi. This is the route looks like right now:

[root@GPA gpa]# route   
Kernel IP routing table 
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface                   
default         gateway         0.0.0.0         UG    6      0        0 tun1                    
10.0.0.0        0.0.0.0         255.255.255.0   U     0      0        0 tun1                    
128.199.114.249 192.168.8.1     255.255.255.255 UGH   0      0        0 eth1                    
128.199.114.249 192.168.8.1     255.255.255.255 UGH   5      0        0 eth1                    
192.168.8.0     0.0.0.0         255.255.255.0   U     211    0        0 eth1                    
192.168.8.1     192.168.8.1     255.255.255.255 UGH   5      0        0 eth1                    
192.168.12.0    0.0.0.0         255.255.255.0   U     0      0        0 wlan0
  1. 128.199.114.249 is the IP of my ssh server
  2. 192.168.8.1 is my modem's default gateway
  3. 192.168.8.100 is my modem's IP (DHCP)
  4. 192.168.12.1 is my raspberry pi IP

This is the badvpn command that I use:

[root@GPA gpa]# badvpn-tun2socks --tundev tun1 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 192.168.12.1:1080 --udpgw-remote-server-addr 127.0.0.1:7300
NOTICE(tun2socks): initializing BadVPN tun2socks 1.999.130
NOTICE(tun2socks): entering event loop
INFO(tun2socks): UDP: from device 21 bytes
INFO(tun2socks): UDP: from device 21 bytes
INFO(tun2socks): UDP: from device 21 bytes
INFO(SocksUdpGwClient): SOCKS error
INFO(SocksUdpGwClient): SOCKS error
INFO(SocksUdpGwClient): SOCKS error

It keeps giving me that error, how do I fix this ?

Mac OS X install BadVPN failed

Everything is running well before I enter the make command : make

[ 42%] Building C object system/CMakeFiles/system.dir/BSignal.c.o
In file included from /Users/Skinner/Documents/VPN/badvpn/system/BSignal.c:34:
/Users/Shoplex/Documents/VPN/badvpn/system/BUnixSignal.h:38:2: error: 
      Unknown signal backend or too many signal backends
#error Unknown signal backend or too many signal backends
 ^
In file included from /Users/Shoplex/Documents/VPN/badvpn/system/BSignal.c:34:
In file included from /Users/Shoplex/Documents/VPN/badvpn/system/BUnixSignal.h:45:
In file included from /Users/Shoplex/Documents/VPN/badvpn/system/BReactor.h:6:
/Users/Shoplex/Documents/VPN/badvpn/system/BReactor_badvpn.h:39:2: error: 
      Unknown event backend or too many event backends
#error Unknown event backend or too many event backends
 ^
2 errors generated.
make[2]: *** [system/CMakeFiles/system.dir/BSignal.c.o] Error 1
make[1]: *** [system/CMakeFiles/system.dir/all] Error 2
make: *** [all] Error 2

ERROR(BTap): DeviceIoControl(TAP_IOCTL_GET_MTU) failed

Hello
I'm trying to run badvpn-tun2socks in Windows and after creating the TAP adapter I get this error:

ERROR(BTap): DeviceIoControl(TAP_IOCTL_GET_MTU) failed

According to http://openvpn.net/index.php/open-source/documentation/install.html you cannot programmatically set the MTU:

"Currently on Windows, the only way to change the TAP-Windows MTU is to go to the adapter advanced properties and do it manually."

and I guess explains why TAP_IOCTL_GET_MTU fails. Perhaps an option to assume a MTU should be added for windows platforms? I.e. --mtu=1500

Oskar

OSX Package?

Is it possible for badvpn to work on OSX (and preferably installed using homebrew)?

Thanks

INFO(SocksUdpGwClient): SOCKS up INFO(SocksUdpGwClient): SOCKS error

This is appeared from tun2socks.exe with "--udpgw-remote-server-addr 127.0.0.1:7300" and the version is 1.999.128.
The remote server is ubuntu 14.04 and set up udpgw(v1.999.129) on it.
What happened,or something i can do to solve it.

INFO(tun2socks): UDP: from device 42 bytes
INFO(tun2socks): UDP: from device 33 bytes
> INFO(SocksUdpGwClient): SOCKS up
INFO(tun2socks): UDP: from device 33 bytes
INFO(tun2socks): UDP: from device 34 bytes
INFO(tun2socks): UDP: from device 42 bytes
INFO(tun2socks): UDP: from device 33 bytes
INFO(tun2socks): UDP: from device 33 bytes
INFO(tun2socks): UDP: from device 33 bytes
INFO(tun2socks): UDP: from device 33 bytes
INFO(tun2socks): UDP: from device 34 bytes
INFO(tun2socks): UDP: from device 34 bytes
INFO(tun2socks): UDP: from device 33 bytes
INFO(tun2socks): UDP: from device 34 bytes
> INFO(SocksUdpGwClient): SOCKS error
INFO(tun2socks): UDP: from device 34 bytes

tun2socks udpgw doesn't work with linux 3.19

I am getting a problem when running tun2socks with linux 3.19. badvpn-tun2socks process takes 100% CPU, and there are no udpgw messages in stdout. TCP tunneling seems to work well, but UDP doesn't. A Ctrl-C or SIGTERM could not terminate the program either, only SIGKILL would do. Downgrading linux kernel to 3.18.x fixes all this.

Build consistently failing at Makefile:4097 (error 2)

This could just be an issue with my current setup, so grave apologies if this issue isn't caused by any of the code. The current build command I'm using is:

NIX_PATH=nixpkgs=/home/samuel/tun2socks_compilation/nixpkgs/ nix-build badvpn/build-win32.nix -A badvpnPkgs.badvpn -o output_link/

And for some reason it always breaks at this point:

g++   -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -DGENERATOR_FILE -static-libstdc++ -static-libgcc  -o build/genattrtab \
    build/genattrtab.o build/rtl.o build/read-rtl.o build/ggc-none.o build/vec.o build/min-insn-modes.o build/gensupport.o build/print-rtl.o build/read-md.o build/errors.o ../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a
build/genattrtab ../../gcc-5.4.0/gcc/common.md ../../gcc-5.4.0/gcc/config/i386/i386.md insn-conditions.md \
        -Atmp-attrtab.c -Dtmp-dfatab.c -Ltmp-latencytab.c
make[1]: *** [Makefile:2154: s-attrtab] Killed
make[1]: Leaving directory '/tmp/nix-build-gcc-5.4.0-i686-w64-mingw32-stage-static.drv-0/build/gcc'
make: *** [Makefile:4097: all-gcc] Error 2
builder for ‘/nix/store/y1ngf8i7z4jrcbrb0y1r4sbvp8hkhh8k-gcc-5.4.0-i686-w64-mingw32-stage-static.drv’ failed with exit code 2
cannot build derivation ‘/nix/store/k8m2292kz0hviif15y4zfwgamcfdiksk-gcc-cross-wrapper.drv’: 1 dependencies couldn't be built
building path(s) ‘/nix/store/mx6qdhnhi8fhgwy3f3k0kxdgkkd0n89j-util-linux-2.28.1-bin’, ‘/nix/store/pl83zf8w4hhjkjz7hjvdql0cg99ajhf5-util-linux-2.28.1-man’, ‘/nix/store/qrhi3r84ddaz974wx5nb5h96i6kv161x-util-linux-2.28.1’, ‘/nix/store/z8kmxpp0z182kn4skb8qzhjs4r7x2s9f-util-linux-2.28.1-dev’
cannot build derivation ‘/nix/store/1xfqn709mgmm0cxrn6p3gzqa1rhjp0cl-mingw-w64-4.0.6.drv’: 1 dependencies couldn't be built
cannot build derivation ‘/nix/store/vc5by7pnscgzg8dpg6cixnziiawllni7-gcc-cross-wrapper.drv’: 1 dependencies couldn't be built
killing process 14839
cannot build derivation ‘/nix/store/jw4zrwifvqa7f57aay6nl4ap2yx5dbyd-badvpn-i686-w64-mingw32.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/jw4zrwifvqa7f57aay6nl4ap2yx5dbyd-badvpn-i686-w64-mingw32.drv’ failed

By the way, I have downloaded the patched version of nixpkgs (to the nixpkgs/ directory).
Thanks a lot for creating this wonderful repository, and I hope my issues are useful so far :)

Regards.

Unexpected behavior with Windows RRAS and TAP_IOCTL_GET_MTU error

I have two virtual machines, the first VM connects to Tor, runs badvpn 1.999.128 and Windows Routing & Remote Access (RRAS) on Windows Server 2016, and a second virtual machine which runs Windows 10 and Firefox. The Firefox VM is configured to use the Tor VM as its gateway and DNS server. Whenever I try to use RRAS NAT to share the Tor network connection with the Firefox VM, and configure RRAS NAT with the TAP adapter as the Public/Full interface, any internet requests for the Firefox VM have their traffic routed to the public internet. If I use internet connection sharing instead of RRAS NAT, everything works as expected and the Firefox VM has its traffic routed over the Tor network. Can you think of why RRAS's NAT feature when using the TAP adapter as the Full/Public interface would not only not route over the Tor network but do so over the public internet instead? This RRAS configuration works fine when I use it with a OpenVPN connection's TAP adapter in a different set of virtual machines.

The Tor VM has 3 interfaces, Ethernet0 is 10.5.1.6, Ethernet1 is 10.7.2.0 and the TAP adapter (Ethernet) is 10.6.4.1.
I am running badvpn-tun2socks with this command:
badvpn-tun2socks.exe --tundev tap0901:Ethernet:10.6.4.1:10.6.0.0:255.255.0.0 --netif-ipaddr 10.6.4.2 --netif-netmask 255.255.0.0 --socks-server-addr 127.0.0.1:9050
The TAP adapter is configured with the IP 10.6.4.1 and does not have a gateway specified.

Can you think of what might be causing this? I would try it with a more recent version of the TAP adapter driver but I receive the TAP_IOCTL_GET_MTU error specified in the following bug report when using OpenVPN 2.3.12, and have to use the workaround (NDIS 5 driver). It seems that andrewkboyd's fix to this bug was not implemented in the version of badvpn i'm using.

#2

Netmask vs prefix and cidr

Is it possible to use netmask in the ncd as compared to having both prefix and cidr in the network config?

Outdated NSS build instructions for windows

The instructions for building NSS (in the INSTALL_WINDOWS file in master) are slightly out of date.
First, the mozilla-build directory no longer contains start-l10n.bat, instead the directory contains the following executables with the same function:

  • shell-start.bat
  • shell-start-msvc2013.bat
  • shell-start-msvc2013-x64.bat
  • shell-start-msvc2015.bat
  • shell-start-msvc2015-x64.bat

The one that should be used for building on modern 64-bit systems is obviously shell-start-msvc2015-x64.bat

Second, the actual build instructions are a little out of date, in particular the variables set using export VARNAME=VARVAL.
First, OS_TARGET=WINNT is obsolete, it's newer replacement being OS_TARGET=WIN95.
This, by the way, was mentioned in their building user guide.
Another thing is, for building on 64-bit systems USE_64 has to be set to 1 (export USE_64=1).

After making these corrections the NSS build was successful for me (Windows 8.1 64-bit 4GB RAM, using mozilla-build, with VS 2013 & 2015 installed, just as the INSTALL-WINDOWS file said).

Finally, the copy_nss script is referencing a folder which no longer exists (NSSOBJ="${NSSDIST}/WINNT..."), and what's more important .lib files which have been renamed, namely libnspr4, libplc4 and libplds4, which (it appears) have been renamed to nspr4, plc4 & plds4 respectively.

By the way, the folder name in the nss/dist directory depends on build variables, so I would strongly recommend using some kind of wildcard, or at least asking the user for what the folder name is.

Most of these corrections come directly from mozilla's NSS Building page, which can be found here:
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Building#Windows

Another thing, I would suggest linking to the building instructions using this link, in order to avoid the same problems in the future.

Thanks a lot for reading this, and I apologize if it turns out these issues are in fact my misunderstanding. Regards.

ICMP support for tun2socks

It would be nice to support ICMP in the same way as UDP (through a udpgw-alike). Is it impossible due to some limitations, or just didn't see the need?

tun2socks to forward udp

hi

I want to use tun2socks to forward tcp and udp.
With test, I found tcp forward success.
for udp,I run badvpn-tun2socks.exe with --udpgw-remote-server-addr and run badvpn-udpgw.exe on the same socks client,but udp can't forward.

could you pls help me with it?

build-win32 failed (Python.h not found)

I'm trying to build the latest badvpn for win32 on a Cenos 6 linux workstation and comes up with following error.

make[4]: Entering directory '/tmp/nix-build-libxml2-2.9.4.drv-0/libxml2-2.9.4/python'
CC libxml.lo
CC libxml2-py.lo
CC types.lo
In file included from types.c:9:0:
libxml_wrap.h:1:20: fatal error: Python.h: No such file or directory
compilation terminated.
libxml2-py.c:3:20: fatal error: Python.h: No such file or directory
compilation terminated.
libxml.c:14:20: fatal error: Python.h: No such file or directory
compilation terminated.
make[4]: *** [Makefile:627: types.lo] Error 1
make[4]: *** Waiting for unfinished jobs....
make[4]: *** [Makefile:627: libxml2-py.lo] Error 1
make[4]: *** [Makefile:627: libxml.lo] Error 1
make[4]: Leaving directory '/tmp/nix-build-libxml2-2.9.4.drv-0/libxml2-2.9.4/python'
make[3]: *** [Makefile:684: all-recursive] Error 1
make[3]: Leaving directory '/tmp/nix-build-libxml2-2.9.4.drv-0/libxml2-2.9.4/python'
make[2]: *** [Makefile:524: all] Error 2
make[2]: Leaving directory '/tmp/nix-build-libxml2-2.9.4.drv-0/libxml2-2.9.4/python'
make[1]: *** [Makefile:1440: all-recursive] Error 1
make[1]: Leaving directory '/tmp/nix-build-libxml2-2.9.4.drv-0/libxml2-2.9.4'
make: *** [Makefile:859: all] Error 2
builder for ‘/nix/store/p9hh6fb4s0d24ymsgl7lr5247c2p7nj2-libxml2-2.9.4.drv’ failed with exit code 2
cannot build derivation ‘/nix/store/y09zrmyn2f3d3any18kwfx2sqign9kk5-libarchive-3.2.1.drv’: 1 dependencies couldn't be built
building path(s) ‘/nix/store/c6vg54vrmx5ax4scxhmdz3pgv96angl3-mingw-w64-4.0.6-headers’
cannot build derivation ‘/nix/store/j853wfk64jxyxd59876ljyyjd3xzx6k7-cmake-3.6.0.drv’: 1 dependencies couldn't be built
killing process 25305
cannot build derivation ‘/nix/store/g23hs781fjygkfrnsiby9mmf9g10b6q7-badvpn-i686-w64-mingw32.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/g23hs781fjygkfrnsiby9mmf9g10b6q7-badvpn-i686-w64-mingw32.drv’ failed

Full build log is here
build.zip

I'm not familiar with NixOS, but I tried to build (configure && make) the package "libxml2-2.9.4" under /nix/store and that succeeded.

tun2socks won't work with tun1

I have openvpn installed and it's using tun0 so I created another tun device, here's my tun2socks command:
badvpn-tun2socks --tundev tun1 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 192.168.1.1:1080 --udpgw-remote-server-addr 192.168.1.1:7300 > /dev/null &
Here's my route commands:

openvpn --mktun --dev tun1 --user root # Create tun1
ifconfig tun1 10.0.0.1 netmask 255.255.255.0
#DEFAULT#
route del -net 0.0.0.0 netmask 0.0.0.0 gw 0.0.0.0
route add default gw 10.0.0.2 metric 6
#INDOSAT#
route add 10.19.19.19 gw 10.64.64.64 metric 5 # My ISP Proxy
route add 202.152.165.39 gw 10.64.64.64 metric 5 #My ISP DNS
route add 114.5.5.77 gw 10.64.64.64 metric 5 # My ISP DNS

After executing those commands my internet just won't work, here are some screenshots:
http://s28.postimg.org/ymba2a2n1/image.png
http://s14.postimg.org/z8swl0141/image.png

compile-udpgw.sh requires libpthread

On Ubuntu 16.04 I need to add -lpthread to compile-udpgw.sh in order for it to compile:

That is, I need to change this:
"${CC}" ${LDFLAGS} "${OBJS[@]}" -o udpgw -lrt
To this:
"${CC}" ${LDFLAGS} "${OBJS[@]}" -o udpgw -lrt -lpthread

In case it's useful, my full build for tun2socks and udpgw looks like this:

mkdir -p $HOME/src
cd $HOME/src
git clone "https://github.com/ambrop72/badvpn"
cd badvpn

vim compile-udpgw.sh
# Now edit the "compile-udpgw.sh" script and change this:
# "${CC}" ${LDFLAGS} "${OBJS[@]}" -o udpgw -lrt
# To this:
# "${CC}" ${LDFLAGS} "${OBJS[@]}" -o udpgw -lrt -lpthread

mkdir -p build
cd build
export OUTDIR=$PWD
export SRCDIR=$(dirname $PWD)
export CC=gcc
export ENDIAN=little
bash $SRCDIR/compile-tun2sock.sh
bash $SRCDIR/compile-udpgw.sh

mkdir -p $HOME/bin/badvpn
cp tun2socks $HOME/bin/badvpn/
cp udpgw $HOME/bin/badvpn/

Attempting to compile without adding -lpthread results in the error:

/usr/bin/ld: BUnixSignal.c.o: undefined reference to symbol 'pthread_sigmask@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line

ERROR(tun2socks): device error (android)

hi ,
when i want to run tun2socks on android i've got this error

06-19 00:01:33.674 14881-17117/net.test.tun2sockstest D/RootShell v1.3: Executing: /data/data/net.test.tun2sockstest/tun2socks --netif-ipaddr 25.25.25.2 --netif-netmask 255.255.255.0 --socks-server-addr 192.168.1.200:808 --tunfd 40 --tunmtu 1500 --logger stdout --loglevel 5 --pid /data/data/net.test.tun2sockstest/tun2socks.pid with context: NORMAL
06-19 00:01:33.694 17123-17123/? D/tun2socks: NOTICE(tun2socks): initializing BadVPN tun2socks 1.999.127
06-19 00:01:33.694 17125-17125/? D/tun2socks: DEBUG(BReactor): Reactor initializing
06-19 00:01:33.694 17125-17125/? D/tun2socks: DEBUG(BSignal): BSignal initializing
06-19 00:01:33.694 17125-17125/? D/tun2socks: ERROR(BReactor): epoll_ctl failed: 17
06-19 00:01:33.694 17125-17125/? D/tun2socks: ERROR(BTap): BReactor_AddFileDescriptor failed
06-19 00:01:33.694 17125-17125/? D/tun2socks: ERROR(tun2socks): BTap_Init2 failed
06-19 00:01:33.694 17125-17125/? D/tun2socks: DEBUG(BReactor): Reactor freeing
06-19 00:01:33.694 17125-17125/? D/tun2socks: NOTICE(tun2socks): exiting
06-19 00:01:33.694 14881-17118/net.test.tun2sockstest D/RootShell v1.3: Read all output
06-19 00:01:35.334 14881-17118/net.test.tun2sockstest D/TUN2SOCKS: 0
06-19 00:01:35.334 14881-17118/net.test.tun2sockstest D/RootShell v1.3: Command 0 finished.

Can I use DNS via tun2socks?

I have complete tun2socks setup. I am running tun2socks with UDP forwarding enabled. TCP seems to work fine.

I want me DNS requests go via tun2socks UDP forwarding facilities.

Is it expected to work?

So far I see that badvpn_tun2socks captures UDP packets but I never got an answer...

Is Possible to lockdown the virtual tun2socks router, to accept only local host connections?

I am running tun2socks on a windows 7 machine, which is a plugged into my public ip address

The machine also runs nat32 which does the nat and routing to all my home computers.

Suddenly i found in nat32 a big list of unknown devices (ipads, iphones....) connected to the 10.0.0 subnet (the tun2socks router).

Question #1 is, is even there a possibility to connect to that router from an outside device?

Question #2 Is there a way to lock down the virtual router?

Does badvpn support failover?

I usually set up 3 ssh tunnels so I have 3 socks5 proxies, does badvpn support failover so that when one of my proxies dies it'll automatically switch to another one?

badvpn-udpgw[338]: ERROR(BDatagram): send failed

I'm running badvpn-udpgw on the server, and noticed many UDP error messages in the log.
I enabled debug level to get more details, but even in that case, the root causes are not apparent (it is not clear which UDP request is really failing, to which destination, etc).

See log excerpt below.

In any case, these errors are not really troublesome. It does not prevent badvpn-tun2socks to work fine and forward DNS queries correctly as far as I can tell. So all in all, I'll probably set the loglevel back to none.

Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(udpgw): client (127.0.0.1:57858): connection 24: initialized
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(udpgw): client (127.0.0.1:57858): connection 24: from client 143 bytes
Sep 25 10:24:56 prime badvpn-udpgw[338]: ERROR(BDatagram): send failed
Sep 25 10:24:56 prime badvpn-udpgw[338]: INFO(udpgw): client (127.0.0.1:57858): connection 24: UDP error
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): Calling epoll_wait
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): epoll_wait returned 1 file descriptors
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): Dispatching file descriptor
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(udpgw): client (127.0.0.1:57858): received keepalive
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): Calling epoll_wait
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): epoll_wait returned 1 file descriptors
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): Dispatching file descriptor
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(udpgw): client (127.0.0.1:57858): received keepalive
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): Calling epoll_wait
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): epoll_wait returned 1 file descriptors
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): Dispatching file descriptor
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(udpgw): client (127.0.0.1:57858): received keepalive
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): Calling epoll_wait
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): epoll_wait returned 1 file descriptors
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): Dispatching file descriptor
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(udpgw): client (127.0.0.1:57858): connection 24: initialized
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(udpgw): client (127.0.0.1:57858): connection 24: from client 143 bytes
Sep 25 10:24:56 prime badvpn-udpgw[338]: ERROR(BDatagram): send failed
Sep 25 10:24:56 prime badvpn-udpgw[338]: INFO(udpgw): client (127.0.0.1:57858): connection 24: UDP error
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): Calling epoll_wait
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): epoll_wait returned 1 file descriptors
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): Dispatching file descriptor
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(udpgw): client (127.0.0.1:57858): received keepalive
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): Calling epoll_wait
Sep 25 10:24:56 prime badvpn-udpgw[338]: DEBUG(BReactor): epoll_wait returned 1 file descriptors
Sep 25 10:26:55 prime badvpn-udpgw[338]: DEBUG(BReactor): Dispatching file descriptor
Sep 25 10:26:55 prime badvpn-udpgw[338]: DEBUG(udpgw): client (127.0.0.1:57858): received keepalive
Sep 25 10:26:55 prime badvpn-udpgw[338]: DEBUG(BReactor): Calling epoll_wait
Sep 25 10:26:55 prime badvpn-udpgw[338]: DEBUG(BReactor): epoll_wait returned 1 file descriptors
Sep 25 10:26:55 prime badvpn-udpgw[338]: DEBUG(BReactor): Dispatching file descriptor

Release build of tun2socks request

have built windows version tun2socks by following the guide, but it's a debug build and it requires VCRUNTIME140D.dll
this dll is not included in Visual C++ Redistributable 2017.
please provide us a release build.
Thanks in advance.

DeviceIoControl(TAP_IOCTL_GET_MTU) failed

I get folowing error when I use NDIS6 driver but it's ok with NDIS5
NOTICE(tun2socks): initializing BadVPN tun2socks 1.999.128
INFO(BTap): Looking for TAP-Win32 with component ID tap0901, name Local Area Con
nection 2
INFO(BTap): Opening device .\Global{B9955714-34F4-4846-BBE3-79F734861EF2}.tap

ERROR(BTap): DeviceIoControl(TAP_IOCTL_GET_MTU) failed
ERROR(tun2socks): BTap_Init failed
NOTICE(tun2socks): exiting

UDP redirection with iptables ?

Hi!
Coming here from Shadowsocks (who use the tun2socks, among other things, under the hood)

I'm trying to achieve the following:

  1. Force UDP AND TCP traffic that is going to a specific remote port to go through the shadowsocks proxy
  2. Force UDP AND TCP traffic originating from a specific port range to go through the shadowsocks proxy

I suspect I could achieve that with tun2socks (which is included with Shadowsocks) but damn me if I knew how. Iptables be killin me

How to protect udp channel.

i don't want to forward udp data, what i should do?
I put the udpgwServerAddress is NULL and udpgwTransparentDNS is false,but it 's alwasy forward upd data.

thanks a lot ,
and sorry for my bad english.

TAP_IOCTL_CONFIG_TUN fails

Hi,
I have Win7, running console prompt as Administrator. I have installed the latest OpenVPN binary and added one tap interface that I renamed to "tap_badvpn".
Here's what I do to set up badvpn:

E:\softs\badvpn-1.999.128-win32\bin>badvpn-tun2socks.exe --tundev tap0901:tap_badvpn:10.0.0.1:10.0.0.255:255.255.255.0 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:8081
NOTICE(tun2socks): initializing BadVPN tun2socks 1.999.128
INFO(BTap): Looking for TAP-Win32 with component ID tap0901, name tap_badvpn
INFO(BTap): Opening device \\.\Global\{38B72935-00B2-4896-B172-D8888929552C}.tap
ERROR(BTap): DeviceIoControl(TAP_IOCTL_CONFIG_TUN) failed
ERROR(tun2socks): BTap_Init failed
NOTICE(tun2socks): exiting

I don't know if my badvpn binaries are up to date. I don't have a Windows compiler.

Is there anything to configure on the tap device? I have set up a static IP address as 10.0.0.1 but it didn't help.

Thanks a lot for your software and support.

Can't access reddit without manually setting up browser's proxy

Hi, I'm sorry this isn't a bug report of tun2socks, this is more like just my curiosity. So reddit is blocked in my country, the only ways to access it are with vpn & ssh tunnel. I use tun2socks with my ssh tunnel, I can access other websites just fine without configuring my browser proxy to my SSH socks proxy but not with reddit. I have to manually setting up a proxy on my browser first to be able to access it. Do you know why that happens ? Is it related to the DNS or anything else? I followed the exact same tutorial as the one you wrote here https://github.com/ambrop72/badvpn/wiki/Tun2socks

Can tun2socks support UDP?

I have read the README.md and found this:

The tun2socks program "socksifes" TCP connections at the network layer.

It seems that the tun2socks does not support UPD.
And it seems that the BadVPN do not support confounding data yet.

So, I believe that if the BadVPN can support confounding data (like obfs) or enable tun2socks to support UDP, it would be more popular, for many people in China Mainland need tools to fight against GFW(the Great Firewall of China), to connect to the real Internet.

Thank you.

UDP performance

Hi all,

I am using tun2socks like as proxy client, I have no problem with performance with TCP( around 300Mbps in my environment by iperf).
But performance for UDP is not good (under 20 Mbps), have packet loss and droped at tun2socks (Out of buffer):

https://github.com/ambrop72/badvpn/blob/master/udpgw_client/UdpGwClient.c (line 340 )
if (!BufferWriter_StartPacket(con->send_if, &out)) { BLog(BLOG_ERROR, "out of buffer"); return; }
Seem that room of buffer is not enough.
Is there any way to improve UDP performance or increase buffer for sending UDP packet.a

Thank you very much.

tun2socks Consuming 100% CPU in Ubuntu Vivid

Output of top

Tasks: 255 total,   2 running, 252 sleeping,   0 stopped,   1 zombie
%Cpu(s): 14.2 us, 17.7 sy,  0.0 ni, 67.9 id,  0.3 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:  12182824 total,  8131116 used,  4051708 free,    86736 buffers
KiB Swap:        0 total,        0 used,        0 free.  4528704 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                
 2317 root      20   0    8916   1148    892 R 100.0  0.0 230:47.52 badvpn-tun2sock                    

Version of badvpn

$ apt-cache show badvpn 
Package: badvpn
Priority: extra
Section: net
Installed-Size: 1381
Maintainer: Ambroz Bizjak <[email protected]>
Architecture: amd64
Version: 1.999.129-1~trusty1
Depends: libc6 (>= 2.14), libnspr4 (>= 2:4.9-2~) | libnspr4-0d (>= 1.8.0.10), libnss3 (>= 2:3.13.4-2~) | libnss3-1d (>= 3.12.0~1.9b1), libssl1.0.0 (>= 1.0.0), sysv-rc (>= 2.88dsf-24) | file-rc (>= 0.8.16)
Filename: pool/main/b/badvpn/badvpn_1.999.129-1~trusty1_amd64.deb
Size: 381748
MD5sum: 4ee69759f9ccfdee48ac9bf2ac9ec178
SHA1: 7d16c1a6d89923e1d75269135b4e8284bea61fe7
SHA256: 08ba4e88f7f482f4e3ec78cf5650288e27da784976b90268d78d8a9cd2ea8d9d
Description: Peer-to-peer VPN and NCD, the Network Configuration Daemon
 BadVPN in a Layer 2 peer-to-peer VPN software.
 Also contains NCD, Network Configuration Daemon, a powerful system
 for network configurations that is really a programming language.
Description-md5: 2cc554d5a2dd72714803d4d6ead37408

Version of Kernel

$ apt-cache show linux-image-generic 
Package: linux-image-generic
Priority: optional
Section: kernel
Installed-Size: 27
Maintainer: Ubuntu Kernel Team <[email protected]>
Architecture: amd64
Source: linux-meta
Version: 3.19.0.15.14
Depends: linux-image-3.19.0-15-generic, linux-image-extra-3.19.0-15-generic, linux-firmware
Recommends: thermald
Filename: pool/main/l/linux-meta/linux-image-generic_3.19.0.15.14_amd64.deb
Size: 2416
MD5sum: e0738e1b7be25935f551df9831f40770
SHA1: d07ad5a841c54c728a406e4b31744dafb3eefd8a
SHA256: 67b8734f1352152529535afe8ead562d592308d892e1535176c165e07a95012c
Description-en: Generic Linux kernel image
 This package will always depend on the latest generic kernel image
 available.
Description-md5: 6d632579c673704f44b290b16e7dbfd1
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 9m

Cannot ping 10.0.0.2 and error "Network is unreachable"

I cannot get badvpn-tun2socks to work on either Ubuntu16.04 or Debian Stretch.
On Ubuntu, I tried with or without firewall. Debian is installed in a VM without FW.

# As user 'superman':
sudo ip tuntap add dev tun0 mode tun user superman
sudo ip addr add 10.0.0.1/24 dev tun0
badvpn-tun2socks --tundev tun0 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:1080
# NOTICE(tun2socks): initializing BadVPN tun2socks 1.999.130
# NOTICE(tun2socks): entering event loop

In a separate window:

ip addr
# 3: tun0: <POINTOPOINT,MULTICAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 500
#     link/none 
#     inet 10.0.0.1/24 scope global tun0
#        valid_lft forever preferred_lft forever
ping 10.0.0.1
# PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
# 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.016 ms
ping 10.0.0.2
# PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.

We get no answer when pinging 10.0.0.2. When adding the default gw to 10.0.0.2, we get an error:

sudo route add default gw 10.0.0.2 metric 6
# SIOCADDRT: Network is unreachable

Multiple DNS servers

Hi,
In NCD, I have noticed that dhcp.dns_servers is an array which obtained is not comma separated or spaces. e.g. 123.2.2.5123.2.2.8
How would I obtain the first entry in the array?
Regards,
George

tun2socks error running on windows VM

Hi, i was trying to run tun2socks on windows7-x86 VM, and i get the following error:

$ badvpn-tun2socks --tundev "tap0901:TUN:10.0.0.1:10.0.0.0:255.255.255.0" --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:1080
NOTICE(tun2socks): initializing BadVPN tun2socks 1.999.128
INFO(BTap): Looking for TAP-Win32 with component ID tap0901, name TUN
INFO(BTap): Opening device \\.\Global\{9EA55347-D894-446D-BC69-487C1923EC6D}.tap

ERROR(BTap): DeviceIoControl(TAP_IOCTL_GET_MTU) failed
ERROR(tun2socks): BTap_Init failed
NOTICE(tun2socks): exiting

Can i have some help here, please? Really need to get it work.

ld.gold linking error

latest git HEAD

ld.gold: error: objs/tun2socks/badvpn/lwip/custom/sys.o: multiple definition of 'tcp_timer_needed'
ld.gold: objs/tun2socks/badvpn/lwip/src/core/timeouts.o: previous definition here
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

my temp fix:

diff --git a/lwip/custom/lwipopts.h b/lwip/custom/lwipopts.h
index f2db0ef3..573a2e29 100644
--- a/lwip/custom/lwipopts.h
+++ b/lwip/custom/lwipopts.h
@@ -72,6 +72,8 @@
 #define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
 #define LWIP_SINGLE_NETIF 1
 
+#define LWIP_TUN2SOCKS_CHANGE
+
 /*
 #define LWIP_DEBUG 1
 #define IP_DEBUG LWIP_DBG_ON
diff --git a/lwip/custom/sys.c b/lwip/custom/sys.c
index dbc1f209..04f16f22 100644
--- a/lwip/custom/sys.c
+++ b/lwip/custom/sys.c
@@ -36,6 +36,8 @@ u32_t sys_now (void)
     return btime_gettime();
 }
 
+/*
 void tcp_timer_needed(void)
 {
 }
+*/
diff --git a/lwip/src/core/timeouts.c b/lwip/src/core/timeouts.c
index 1290661d..88468e2b 100644
--- a/lwip/src/core/timeouts.c
+++ b/lwip/src/core/timeouts.c
@@ -147,12 +147,14 @@ tcpip_tcp_timer(void *arg)
 void
 tcp_timer_needed(void)
 {
+#ifndef LWIP_TUN2SOCKS_CHANGE
   /* timer is off but needed again? */
   if (!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs)) {
     /* enable and start timer */
     tcpip_tcp_timer_active = 1;
     sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
   }
+#endif
 }
 #endif /* LWIP_TCP */
 

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.