@@ -28,22 +28,26 @@ public IFace(VPNService vpnService) {
2828 }
2929
3030 @ Override
31- public long configureInterface (String address , long mtu , String dns , String searchDomainsString , String routesString ) throws Exception {
31+ public long configureInterface (String address , String addressV6 , long mtu , String dns , String searchDomainsString , String routesString ) throws Exception {
3232 String [] searchDomains = toSearchDomains (searchDomainsString );
3333 LinkedList <Route > routes = toRoutes (routesString );
3434
3535 InetNetwork addr = InetNetwork .parse (address );
36+ InetNetwork addrV6 = null ;
37+ if (addressV6 != null && !addressV6 .isEmpty ()) {
38+ addrV6 = InetNetwork .parse (addressV6 );
39+ }
3640 long fd = -1 ;
3741
3842 try {
39- fd = createTun (addr .getAddress ().getHostAddress (), addr .getMask (), (int ) mtu , dns , searchDomains , routes );
43+ fd = createTun (addr .getAddress ().getHostAddress (), addr .getMask (), addrV6 , (int ) mtu , dns , searchDomains , routes );
4044 } catch (Exception e ) {
4145 Log .e (LOGTAG , "failed to create tunnel" , e );
4246 }
4347
4448 // only set the currently used TUN parameters if createTun didn't throw exceptions
4549 if (fd != -1 ) {
46- this .vpnService .setCurrentTUNParameters (new TUNParameters (address , mtu , dns , searchDomainsString , routesString ));
50+ this .vpnService .setCurrentTUNParameters (new TUNParameters (address , addressV6 , mtu , dns , searchDomainsString , routesString ));
4751 }
4852
4953 return fd ;
@@ -57,9 +61,13 @@ public boolean protectSocket(int fd) {
5761 return true ;
5862 }
5963
60- private int createTun (String ip , int prefixLength , int mtu , String dns , String [] searchDomains , LinkedList <Route > routes ) throws Exception {
64+ private int createTun (String ip , int prefixLength , InetNetwork addrV6 , int mtu , String dns , String [] searchDomains , LinkedList <Route > routes ) throws Exception {
6165 VpnService .Builder builder = vpnService .getBuilder ();
6266 builder .addAddress (ip , prefixLength );
67+ if (addrV6 != null ) {
68+ builder .addAddress (addrV6 .getAddress ().getHostAddress (), addrV6 .getMask ());
69+ Log .d (LOGTAG , "add IPv6 address: " + addrV6 .getAddress ().getHostAddress () + "/" + addrV6 .getMask ());
70+ }
6371 builder .allowFamily (OsConstants .AF_INET );
6472 builder .allowFamily (OsConstants .AF_INET6 );
6573 builder .setMtu (mtu );
0 commit comments