mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
resolver: per service, defaultresolve, fakeresolve or sysresolve
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Waiting to run
Each service resolves names the way the last of defaultresolve (the name servers in force, configured or the system's with the hosts file), fakeresolve (127.0.0.2) and sysresolve (the C library) read before it says; the last one in the configuration also applies outside services. defaultresolve is the new command, and the default. The name servers and the hosts file no longer depend on the mode: nserver lines, or the system's, are always in force, so dnspr keeps forwarding; with fakeresolve it does not, as before. fakeresolver moves to common.c, which the standalone services link without resolve.c. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
994526dbc4
commit
3d20e1104e
14 files changed
+181
-101
No files matched your search
+27
-15
@@ -1,6 +1,7 @@
|
||||
"""The system's name servers and hosts file as the default resolver: with
|
||||
no nserver in a configuration, names in the hosts file are answered from
|
||||
it; with nserver lines, or sysresolve (the system routines), it is not."""
|
||||
it; with nserver lines it is not. Each service resolves names the way the
|
||||
last of defaultresolve, sysresolve and fakeresolve before it says."""
|
||||
|
||||
import os
|
||||
import re
|
||||
@@ -82,25 +83,36 @@ def run(t):
|
||||
t.ne(["127.0.0.1"], t.dns_query(other, "localhost") or [],
|
||||
"with nserver, the hosts file is not used")
|
||||
|
||||
# sysresolve: the system routines resolve names, and nothing is imported
|
||||
# for dnspr to answer from
|
||||
sysport, proxy, srv = t.free_port(), t.free_port(), t.free_port()
|
||||
t.start("sysdns_sysresolve", f"""
|
||||
# each service resolves the way the command before it says: fake (to
|
||||
# 127.0.0.2, where the server is not), the system routines (no
|
||||
# nsrecord) or the default (the system's name servers, and nsrecord)
|
||||
fake, system, default, srv = t.free_port(), t.free_port(), t.free_port(), t.free_port()
|
||||
t.start("sysdns_modes", f"""
|
||||
log
|
||||
nscache 1024
|
||||
nsrecord only3proxy.test 127.0.0.1
|
||||
flush
|
||||
sysresolve
|
||||
auth iponly
|
||||
allow *
|
||||
dnspr -p{sysport}
|
||||
proxy -p{proxy}
|
||||
fakeresolve
|
||||
proxy -p{fake}
|
||||
sysresolve
|
||||
proxy -p{system}
|
||||
defaultresolve
|
||||
proxy -p{default}
|
||||
flush
|
||||
auth iponly
|
||||
allow *
|
||||
http echo * /echo**
|
||||
httpsrv -p{srv}
|
||||
""", ports=[proxy, srv])
|
||||
wait(t, sysport, "localhost")
|
||||
t.ne(["127.0.0.1"], t.dns_query(sysport, "localhost") or [],
|
||||
"with sysresolve, dnspr has no hosts file names")
|
||||
t.eq(200, t.http(f"http://localhost:{srv}/echo", proxy=f"127.0.0.1:{proxy}").status,
|
||||
"and names resolve through the system routines")
|
||||
httpsrv -i127.0.0.1 -p{srv}
|
||||
""", ports=[fake, system, default, srv])
|
||||
t.eq(200, t.http(f"http://localhost:{srv}/echo", proxy=f"127.0.0.1:{default}").status,
|
||||
"defaultresolve: a name of the hosts file resolves")
|
||||
t.eq(200, t.http(f"http://only3proxy.test:{srv}/echo", proxy=f"127.0.0.1:{default}").status,
|
||||
"and an nsrecord name")
|
||||
t.eq(200, t.http(f"http://localhost:{srv}/echo", proxy=f"127.0.0.1:{system}").status,
|
||||
"sysresolve: names resolve through the system routines")
|
||||
t.ne(200, t.http(f"http://only3proxy.test:{srv}/echo", proxy=f"127.0.0.1:{system}").status,
|
||||
"which know no nsrecord name")
|
||||
t.ne(200, t.http(f"http://localhost:{srv}/echo", proxy=f"127.0.0.1:{fake}").status,
|
||||
"fakeresolve: every name is 127.0.0.2, in a service before the others")
|
||||
Reference in new issue
Block a user