Skip to content

Commit

Permalink
feat: support tun mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tzmax committed Jan 23, 2023
1 parent 445c7e3 commit 9f63ccc
Show file tree
Hide file tree
Showing 51 changed files with 1,083 additions and 48 deletions.
49 changes: 40 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,50 @@

> This repo is based on the [Cenmrev/V2RayX](https://github.com/Cenmrev/V2RayX) project for maintenance and update, uses the [Xray-core](https://github.com/XTLS/Xray-core) implementation to support the VLESS and XTLS protocol, and the copyright of the application belongs to the original author [@Contents](https://github.com/Cenmrev). Pay tribute to [@Contents](https://github.com/Cenmrev), Thanks to the [@XTLS](https://github.com/XTLS) community and all contributors
## What is XTLS? Xray?

## What is V2Ray?
**READ THIS**: [XTLS? Xray? V2Ray?](https://xtls.github.io).

**READ THIS**: [Project V2Ray](http://www.v2ray.com).
**YOU SHOULD READ XTLS'S OFFICIAL INSTRUCTION BEFORE USING V2RAYXS!**

**YOU SHOULD READ V2RAY'S OFFICIAL INSTRUCTION BEFORE USING V2RAYX!**
## What is Tun Mode? (Experimental)

> ~~Other V2Ray clients on macOS: [V2RayU](https://github.com/yanue/v2rayu).
(Not related to or endorsed by authors of this repo. USE AT YOUR OWN RISK. The project may have failed.)~~
**Warn**: You must read this part of the document before using tun mode.

## What is XTLS? Xray?
First of all, please note that this function is an experimental function and is still under development and design. Due to the particularity of the tun mode, I hope you can use it after fully understanding it.

**READ THIS**: [XTLS? Xray? V2Ray?](https://xtls.github.io).
This mode adopts the tun2socks method to forward all traffic, realizes the creation of a utun virtual network card device, and transmits the traffic of the tun device to your server through the socks5 proxy, and then the application sets up the routing table, and sets the default gateway to this tun device (please Note that this step may cause the default gateway routing settings of your device to be damaged. Although I have done a backup and repair process in the application, I cannot guarantee that it will be effective on all devices, please use it with caution!)

Finally, if you are interested in this technology, you can also try to contact me or submit a PR to help me improve this function. If you can recommend this software to friends or post a blog and be able to link this project in other post replies, I will Very happy 😋, thank you for your attention and contribution (Welcome to contribute documents in other languages)

1. Please understand what transparent proxy is, if PAC mode and global mode can meet your needs, please try to use it

2. You have a certain understanding of the computer network and can solve the network problem of your device independently

### Have you encountered a problem?

Q: After using tun mode, the device is disconnected from the network? (recommended reference this page [What is a transparent proxy?](https://xtls.github.io/Xray-docs-next/document/level-2/transparent_proxy/transparent_proxy.html))

A: It may be that the route of the default gateway is broken. You can check your routing table by executing the `netstat -r` command through the device terminal. Normally, there will be a `default` route, as follows

```
tzmaxdeMacBookPro: tzmax$ netstat -r
Routing tables
Internet:
Destination Gateway Flags Netif Expire
default 192.168.1.1 UGScg en0
127 localhost UCS lo0
localhost localhost UH lo0
………
```

Q: Which tun device does the V2RayXS create?

A: The name of the tun device on macos will be determined by the system, but the tun device created by V2RayXS will be bound to the `10.0.0.0` network segment by default, which can be used as a reference to find

for more questions, you can also check issues first, and submit issues if you do not find a solution.

**YOU SHOULD READ XTLS'S OFFICIAL INSTRUCTION BEFORE USING V2RAYXS!**
## Download V2RayXS

Download from [Releases](https://github.com/tzmax/V2RayXS/releases).
Expand Down Expand Up @@ -80,6 +109,8 @@ So, to totally uninstall V2RayXS, just delete V2RayXS.app and the files above. :

## Acknowledge

This repo is based on the [Cenmrev/V2RayX](https://github.com/Cenmrev/V2RayX) project for maintenance and update.

V2RayXS uses [GCDWebServer](https://github.com/swisspol/GCDWebServer) to provide a local pac server. V2RayXS also uses many ideas and codes from [ShadowsocksX](https://github.com/shadowsocks/shadowsocks-iOS/tree/master), especially, the codes of [v2rays_sysconfig](https://github.com/tzmax/V2RayXS/blob/master/v2rayx_sysconf/main.m) are simply copied from [shadowsocks_sysconf](https://github.com/shadowsocks/shadowsocks-iOS/blob/master/shadowsocks_sysconf/main.m) with some modifications.

## Donation
Expand All @@ -88,7 +119,7 @@ If Project V2Ray or V2RayX (V2RayXS) helped you, you can also help us by donatio

To donate to Project V2Ray, you may refer to [this page](https://www.v2ray.com/chapter_00/02_donate.html).

To donate to Project Xray, you may refer to [this page](https://xtls.github.io/#%E5%B8%AE%E5%8A%A9-xray-%E5%8F%98%E5%BE%97%E6%9B%B4%E5%BC%BA).
To donate to Project Xray, you may refer to [this page](https://xtls.github.io/#%E5%B8%AE%E5%8A%A9-xray-%E5%8F%98%E5%BE%97%E6%9B%B4%E5%BC%BA).

## Disclaimer

Expand Down
32 changes: 16 additions & 16 deletions V2RayX/AdvancedWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="540" height="455"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1050"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1440"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="540" height="455"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down Expand Up @@ -168,15 +168,15 @@ Gw
<rect key="frame" x="145" y="17" width="332" height="290"/>
<autoresizingMask key="autoresizingMask"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="nNS-kZ-Fe2">
<rect key="frame" x="0.0" y="0.0" width="332" height="290"/>
<rect key="frame" x="0.0" y="0.0" width="317" height="275"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="u9b-6e-BFb">
<rect key="frame" x="0.0" y="0.0" width="332" height="290"/>
<rect key="frame" x="0.0" y="0.0" width="317" height="275"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="332" height="290"/>
<size key="minSize" width="317" height="275"/>
<size key="maxSize" width="332" height="10000000"/>
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
<connections>
Expand All @@ -186,11 +186,11 @@ Gw
</subviews>
</clipView>
<scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="oNE-8a-ecg">
<rect key="frame" x="0.0" y="274" width="332" height="16"/>
<rect key="frame" x="0.0" y="275" width="317" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="WPy-9F-0mh">
<rect key="frame" x="316" y="0.0" width="16" height="290"/>
<rect key="frame" x="317" y="0.0" width="15" height="275"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down Expand Up @@ -1059,18 +1059,18 @@ will match all private IPs.</string>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ie4-oz-k96">
<rect key="frame" x="8" y="32" width="260" height="133"/>
<rect key="frame" x="8" y="34" width="260" height="133"/>
<autoresizingMask key="autoresizingMask"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="RDn-zh-dIS">
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>
<rect key="frame" x="0.0" y="0.0" width="245" height="133"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="1mD-il-bEM">
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>
<rect key="frame" x="0.0" y="0.0" width="245" height="133"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="260" height="133"/>
<size key="minSize" width="245" height="133"/>
<size key="maxSize" width="264" height="10000000"/>
<attributedString key="textStorage">
<fragment content="domain list">
Expand All @@ -1090,7 +1090,7 @@ will match all private IPs.</string>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="V6i-GY-DXa">
<rect key="frame" x="244" y="0.0" width="16" height="133"/>
<rect key="frame" x="245" y="0.0" width="15" height="133"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down Expand Up @@ -1127,18 +1127,18 @@ Gw
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bYJ-jn-eiL">
<rect key="frame" x="8" y="32" width="260" height="133"/>
<rect key="frame" x="9" y="33" width="260" height="133"/>
<autoresizingMask key="autoresizingMask"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="jPy-Y0-jqx">
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>
<rect key="frame" x="0.0" y="0.0" width="245" height="133"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="3kN-VI-6Jc">
<rect key="frame" x="0.0" y="0.0" width="260" height="133"/>
<rect key="frame" x="0.0" y="0.0" width="245" height="133"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="260" height="133"/>
<size key="minSize" width="245" height="133"/>
<size key="maxSize" width="264" height="10000000"/>
<attributedString key="textStorage">
<fragment content="ip list">
Expand All @@ -1158,7 +1158,7 @@ Gw
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="jgM-15-0UD">
<rect key="frame" x="244" y="0.0" width="16" height="133"/>
<rect key="frame" x="245" y="0.0" width="15" height="133"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down
4 changes: 3 additions & 1 deletion V2RayX/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
typedef enum ProxyMode : NSInteger{
pacMode,
globalMode,
manualMode
manualMode,
tunMode
} ProxyMode;


Expand Down Expand Up @@ -91,6 +92,7 @@ int runCommandLine(NSString* launchPath, NSArray* arguments);
@property (weak) IBOutlet NSMenu *ruleSetMenuList;
@property (weak, nonatomic) IBOutlet NSMenuItem *globalModeItem;
@property (weak) IBOutlet NSMenuItem *manualModeItem;
@property (weak) IBOutlet NSMenuItem *tunModeItem;
@property (weak, nonatomic) IBOutlet NSMenuItem *serversItem;
@property (weak, nonatomic) IBOutlet NSMenu *serverListMenu;
@property (weak, nonatomic) IBOutlet NSMenu *pacListMenu;
Expand Down
Loading

0 comments on commit 9f63ccc

Please sign in to comment.