Giter Site home page Giter Site logo

Comments (16)

eycorsican avatar eycorsican commented on August 16, 2024 1
    protectFd := func(s VpnService, fd int) error {
        if s.Protect(fd) {
            return nil
        } else {
            return errors.New(fmt.Sprintf("failed to protect fd %v", fd))
        }
    }
    netCtlr := func(network, address string, fd uintptr) error {
        return protectFd(vpnService, int(fd))
    }

    net.DefaultResolver = &net.Resolver{
        PreferGo: true,
        Dial: func(ctx context.Context, network, addr string) (net.Conn, error) {
            dialer := &net.Dialer{
                DualStack: true,
                Control: func(network, address string, c syscall.RawConn) error {
                    return c.Control(func(fd uintptr) {
                        netCtlr(network, address, fd)
                    })
                },
            }
            return dialer.DialContext(ctx, network, localDNS)
        },
    }

from kitsunebi-android.

rurirei avatar rurirei commented on August 16, 2024

great thanks. https://github.com/rurirei/go-libv2ray/commit/9f1e33e

from kitsunebi-android.

rurirei avatar rurirei commented on August 16, 2024

great thanks. rurirei/go-libv2ray@9f1e33e

sorry for asking. how do i forward dns traffic to v2ray inbound from tun2socks? i set net.defaultResolver with addr 127.0.0.1:10088 (localDns string) and set Dokodemo-Door inbound (listen on port 10088, address 8.8.8.8 port 53)

PrepareDomain err: lookup server.address.domain on [::1]:53: read udp 127.0.0.1:48822->127.0.0.1:10088: read: connection refused

from kitsunebi-android.

eycorsican avatar eycorsican commented on August 16, 2024

I don't remember the details, but I never use dokodemo-door to handle DNS, instead you could route DNS traffic to a DNS outbound:

            {
                "inboundTag": ["tun2socks"],
                "network": "udp",
                "port": 53,
                "outboundTag": "dns-out",
                "type": "field"
            },

from kitsunebi-android.

rurirei avatar rurirei commented on August 16, 2024

though what is inbound tun2socks, i did thought it to Dokodemo inbound.

from kitsunebi-android.

eycorsican avatar eycorsican commented on August 16, 2024

You attach a ctx with a "tun2socks" tag when dialing connections with a V instance, then v2ray will recognize those traffic are coming from "tun2socks":

    ctx = vsession.ContextWithInbound(ctx, &vsession.Inbound{Tag: "tun2socks"})
c, err := vcore.Dial(ctx, h.v, dest)

from kitsunebi-android.

rurirei avatar rurirei commented on August 16, 2024

You attach a ctx with a "tun2socks" tag when dialing connections with a V instance, then v2ray will recognize those traffic are coming from "tun2socks":

    ctx = vsession.ContextWithInbound(ctx, &vsession.Inbound{Tag: "tun2socks"})
c, err := vcore.Dial(ctx, h.v, dest)

thanks for reply, how to handle dns traffic from net.DefaultResolver with vcore.Dial(ctx, h.v, dest) then?

from kitsunebi-android.

eycorsican avatar eycorsican commented on August 16, 2024

The fd is protected as you can see in the code snippet above, protected traffic won't go into v2ray, that's why it's called local dns.

from kitsunebi-android.

rurirei avatar rurirei commented on August 16, 2024

so i was thought meanings of local dns on anything wrong.

from kitsunebi-android.

rurirei avatar rurirei commented on August 16, 2024

android:defaultValue="223.5.5.5"
android:key="@string/local_dns"
android:summary="The DNS server that will be used by the freedom outbound (in case you are using AsIs as the freedom outbound's domain strategy) or for resolving domain names of outbound servers, and these DNS requests won't be logged to proxy log. Moreover, non A/AAAA DNS queries from the OS will also be sent to this DNS server, they will be treated as normal UDP traffic."
android:title="Local DNS"

sorry but could you give some more function explaination of Local DNS?

from kitsunebi-android.

rurirei avatar rurirei commented on August 16, 2024

i was misunderstood this to the similar to tun2socks --dnsgw 127.0.0.1:10088.

so i was thought meanings of local dns on anything wrong.

from kitsunebi-android.

rurirei avatar rurirei commented on August 16, 2024

I don't remember the details, but I never use dokodemo-door to handle DNS, instead you could route DNS traffic to a DNS outbound:

            {
                "inboundTag": ["tun2socks"],
                "network": "udp",
                "port": 53,
                "outboundTag": "dns-out",
                "type": "field"
            },

but local dns traffic won't into v2ray..

from kitsunebi-android.

eycorsican avatar eycorsican commented on August 16, 2024

It means DNS traffic initiated from this resolver will definitely go into the internet directly, no proxying, that's it.

    net.DefaultResolver = &net.Resolver{

I think what you missed here is only the VPN itself (only the Go code) will use this resolver. And you still need to handle DNS traffic coming from other applications, those traffic should be routed to a DNS outbound.

from kitsunebi-android.

rurirei avatar rurirei commented on August 16, 2024

only the VPN itself (only the Go code) will use this resolver

this is exactly i missed.

need to handle DNS traffic coming from other applications

i dont know how should to done this

those traffic should be routed to a DNS outbound

v2ray dns handle its dns-outbound if IP query. is this "Moreover, non A/AAAA DNS queries from the OS will also be sent to this DNS server"?

from kitsunebi-android.

eycorsican avatar eycorsican commented on August 16, 2024

v2ray dns handle its dns-outbound if IP query. is this "Moreover, non A/AAAA DNS queries from the OS will also be sent to this DNS server"?

I forgot, I'm not sure about this without looking into the code.

from kitsunebi-android.

rurirei avatar rurirei commented on August 16, 2024

gave this up.

from kitsunebi-android.

Related Issues (20)

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.