mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-26 23:59:41 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f65105637 | ||
|
|
0d2554614d | ||
|
|
d323ab2d5a | ||
|
|
570cbe307b | ||
|
|
ca70026d27 | ||
|
|
7ad964d6e8 | ||
|
|
31438b7c90 |
No files matched your search
@@ -510,9 +510,13 @@ conditions.</p>
|
|||||||
<i><radius_server_2</i>[:<i>port</i>][/<i>local_address_2</i>]
|
<i><radius_server_2</i>[:<i>port</i>][/<i>local_address_2</i>]
|
||||||
<br>
|
<br>
|
||||||
Configures RADIUS servers to be used for logging and
|
Configures RADIUS servers to be used for logging and
|
||||||
authentication (log and auth types must be set to radius).
|
authentication (log and auth types must be set to radius). A
|
||||||
port and local address to use with given server may be
|
server is a name or an address, resolved when the
|
||||||
specified. <br>
|
configuration is read. port and local address to use with
|
||||||
|
given server may be specified: the port named is the one
|
||||||
|
authentication is asked on, and the accounting requests of
|
||||||
|
the same server go to the port after it (1812 and 1813 by
|
||||||
|
default). <br>
|
||||||
Attributes within request: User-Name, Password: (username
|
Attributes within request: User-Name, Password: (username
|
||||||
and password if presented by client), Service Type:
|
and password if presented by client), Service Type:
|
||||||
Authenticate-Only, NAS-Port-Type: NAS-Port-Virtual,
|
Authenticate-Only, NAS-Port-Type: NAS-Port-Virtual,
|
||||||
@@ -534,9 +538,12 @@ experimental.</p>
|
|||||||
<p style="margin-left:9%; margin-top: 1em"><b>nserver</b>
|
<p style="margin-left:9%; margin-top: 1em"><b>nserver</b>
|
||||||
<i><ipaddr></i>[:<i>port</i>][/<i>tcp</i>] <br>
|
<i><ipaddr></i>[:<i>port</i>][/<i>tcp</i>] <br>
|
||||||
Nameserver to use for name resolutions. If none specified
|
Nameserver to use for name resolutions. If none specified
|
||||||
system routines for name resolution is used. Optional port
|
system routines for name resolution is used. A server that
|
||||||
number may be specified. If optional /tcp is added to IP
|
answers with an error (FORMERR, SERVFAIL, REFUSED and the
|
||||||
address, name resolution is performed over TCP. An IPv6
|
like) is passed over for the next one, while a name answered
|
||||||
|
with no data, or as not there, ends the search. Optional
|
||||||
|
port number may be specified. If optional /tcp is added to
|
||||||
|
IP address, name resolution is performed over TCP. An IPv6
|
||||||
address has to be enclosed in square brackets: <b><br>
|
address has to be enclosed in square brackets: <b><br>
|
||||||
nserver 1.1.1.1 <br>
|
nserver 1.1.1.1 <br>
|
||||||
nserver [2001:4860:4860::8844] <br>
|
nserver [2001:4860:4860::8844] <br>
|
||||||
|
|||||||
+7
-2
@@ -506,7 +506,10 @@ network conditions.
|
|||||||
\fI<NAS_SECRET>\fR \fI<radius_server_1\fR[:\fIport\fR][/\fIlocal_address_1\fR]\fR \fI<radius_server_2\fR[:\fIport\fR][/\fIlocal_address_2\fR]\fR
|
\fI<NAS_SECRET>\fR \fI<radius_server_1\fR[:\fIport\fR][/\fIlocal_address_1\fR]\fR \fI<radius_server_2\fR[:\fIport\fR][/\fIlocal_address_2\fR]\fR
|
||||||
.br
|
.br
|
||||||
Configures RADIUS servers to be used for logging and authentication (log and auth types
|
Configures RADIUS servers to be used for logging and authentication (log and auth types
|
||||||
must be set to radius). port and local address to use with given server may be specified.
|
must be set to radius). A server is a name or an address, resolved when the
|
||||||
|
configuration is read. port and local address to use with given server may be specified:
|
||||||
|
the port named is the one authentication is asked on, and the accounting requests of
|
||||||
|
the same server go to the port after it (1812 and 1813 by default).
|
||||||
.br
|
.br
|
||||||
Attributes within request: User-Name, Password: (username and password if presented by client),
|
Attributes within request: User-Name, Password: (username and password if presented by client),
|
||||||
Service Type: Authenticate-Only,
|
Service Type: Authenticate-Only,
|
||||||
@@ -530,7 +533,9 @@ Use \fBauthcache\fR to speedup authentication. RADIUS feature is currently exper
|
|||||||
.br
|
.br
|
||||||
Nameserver to use for name resolutions. If none specified
|
Nameserver to use for name resolutions. If none specified
|
||||||
system routines for name resolution is
|
system routines for name resolution is
|
||||||
used. Optional port number may be specified.
|
used. A server that answers with an error (FORMERR, SERVFAIL, REFUSED
|
||||||
|
and the like) is passed over for the next one, while a name answered
|
||||||
|
with no data, or as not there, ends the search. Optional port number may be specified.
|
||||||
If optional /tcp is added to IP address, name resolution is
|
If optional /tcp is added to IP address, name resolution is
|
||||||
performed over TCP.
|
performed over TCP.
|
||||||
An IPv6 address has to be enclosed in square brackets:
|
An IPv6 address has to be enclosed in square brackets:
|
||||||
|
|||||||
+2
-2
@@ -1776,8 +1776,8 @@ static int h_radius(int argc, unsigned char **argv){
|
|||||||
*s = 0;
|
*s = 0;
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
if( !getip46(46, argv[nradservers + 2], (struct sockaddr *)&radiuslist[nradservers].authaddr)) return 1;
|
if(parsehost(46, argv[nradservers + 2], (struct sockaddr *)&radiuslist[nradservers].authaddr)) return 1;
|
||||||
if( s && !getip46(46, (unsigned char *)s, (struct sockaddr *)&radiuslist[nradservers].localaddr)) return 2;
|
if(s && parsehost(46, (unsigned char *)s, (struct sockaddr *)&radiuslist[nradservers].localaddr)) return 2;
|
||||||
if(!*SAPORT(&radiuslist[nradservers].authaddr))*SAPORT(&radiuslist[nradservers].authaddr) = htons(1812);
|
if(!*SAPORT(&radiuslist[nradservers].authaddr))*SAPORT(&radiuslist[nradservers].authaddr) = htons(1812);
|
||||||
port = ntohs(*SAPORT(&radiuslist[nradservers].authaddr));
|
port = ntohs(*SAPORT(&radiuslist[nradservers].authaddr));
|
||||||
radiuslist[nradservers].logaddr = radiuslist[nradservers].authaddr;
|
radiuslist[nradservers].logaddr = radiuslist[nradservers].authaddr;
|
||||||
|
|||||||
+5
-5
@@ -224,12 +224,12 @@ void * dnsprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
buf[0] = cid[0];
|
buf[0] = cid[0];
|
||||||
buf[1] = cid[1];
|
buf[1] = cid[1];
|
||||||
if(buf[6] || buf[7]){
|
/* the answer goes to the client as it is, its code with no records
|
||||||
if(socksendto(param, param->clisock, (struct sockaddr *)¶m->sincr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
|
among them: the name not found is the server's word, not ours */
|
||||||
RETURN(822);
|
if(socksendto(param, param->clisock, (struct sockaddr *)¶m->sincr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
|
||||||
}
|
RETURN(822);
|
||||||
RETURN(0);
|
|
||||||
}
|
}
|
||||||
|
RETURN(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!ip) {
|
if(!ip) {
|
||||||
|
|||||||
+7
-1
@@ -156,7 +156,13 @@ uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_
|
|||||||
continue; /* question does not match the query */
|
continue; /* question does not match the query */
|
||||||
}
|
}
|
||||||
if((na = buf[7] + (((unsigned short)buf[6])<<8)) < 1) {
|
if((na = buf[7] + (((unsigned short)buf[6])<<8)) < 1) {
|
||||||
return 0;
|
switch(buf[3] & 0x0F){
|
||||||
|
case 0: /* the name has no address */
|
||||||
|
case 3: /* the name is not there */
|
||||||
|
return 0;
|
||||||
|
default: /* the server failed: ask the next one */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for(k = 13; k<len && buf[k]; k++) {
|
for(k = 13; k<len && buf[k]; k++) {
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-10
@@ -335,6 +335,7 @@ void * tlsprchild(struct clientparam* param) {
|
|||||||
int lv=-1;
|
int lv=-1;
|
||||||
char proto[PROTOLEN]="-";
|
char proto[PROTOLEN]="-";
|
||||||
int snipos = 0;
|
int snipos = 0;
|
||||||
|
int snlen = 0;
|
||||||
PROXYSERVICE stlsproto = param->clientstarttls? param->clientstarttls :
|
PROXYSERVICE stlsproto = param->clientstarttls? param->clientstarttls :
|
||||||
(param->starttls? param->starttls : param->srv->srvstarttls);
|
(param->starttls? param->starttls : param->srv->srvstarttls);
|
||||||
|
|
||||||
@@ -358,16 +359,7 @@ void * tlsprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
else if (parsehostname(sni, param, param->srv->targetport? ntohs(param->srv->targetport):starttlsport(stlsproto))) RETURN (100);
|
else if (parsehostname(sni, param, param->srv->targetport? ntohs(param->srv->targetport):starttlsport(stlsproto))) RETURN (100);
|
||||||
if (!param->hostname)param->hostname = (unsigned char *)strdup(sni);
|
if (!param->hostname)param->hostname = (unsigned char *)strdup(sni);
|
||||||
if(param->srv->s_option && snipos && res > 1){
|
snlen = res;
|
||||||
int len;
|
|
||||||
|
|
||||||
len = socksend(param, param->remsock, param->clibuf+param->clioffset,snipos + (res/2), conf.timeouts[STRING_S]);
|
|
||||||
if(len != snipos + (res/2)){
|
|
||||||
RETURN(310);
|
|
||||||
}
|
|
||||||
param->clioffset += snipos + (res/2);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (res < 0 && param->srv->requirecert) RETURN(310-res);
|
else if (res < 0 && param->srv->requirecert) RETURN(310-res);
|
||||||
}
|
}
|
||||||
@@ -387,6 +379,17 @@ void * tlsprchild(struct clientparam* param) {
|
|||||||
return (void *)param->redirectfunc;
|
return (void *)param->redirectfunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(param->srv->s_option && snipos && snlen > 1){
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = socksend(param, param->remsock, param->clibuf+param->clioffset,snipos + (snlen/2), conf.timeouts[STRING_S]);
|
||||||
|
if(len != snipos + (snlen/2)){
|
||||||
|
RETURN(310);
|
||||||
|
}
|
||||||
|
param->clioffset += snipos + (snlen/2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(stlsproto){
|
if(stlsproto){
|
||||||
res = srvstarttls(param, stlsproto);
|
res = srvstarttls(param, stlsproto);
|
||||||
if(res){
|
if(res){
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
"""Name resolution: a server answering with an error is passed over, one
|
||||||
|
that says the name is not there ends the search.
|
||||||
|
|
||||||
|
A proxy resolves the destination by asking the configured name servers in
|
||||||
|
order. The first one here answers FORMERR to everything; the second answers
|
||||||
|
from a list. A request through the proxy reaches its destination, which
|
||||||
|
proves the second server was asked, and a name the second server says is
|
||||||
|
not there is not resolved by anyone else.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import socket
|
||||||
|
import struct
|
||||||
|
import threading
|
||||||
|
|
||||||
|
|
||||||
|
class DnsServer:
|
||||||
|
"""Answers every query with a fixed rcode, and A records for names it
|
||||||
|
knows: the question is echoed, so the answer parses everywhere."""
|
||||||
|
|
||||||
|
def __init__(self, rcode, records):
|
||||||
|
self.rcode = rcode
|
||||||
|
self.records = records
|
||||||
|
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
self.sock.bind(("127.0.0.1", 0))
|
||||||
|
self.port = self.sock.getsockname()[1]
|
||||||
|
self.thread = threading.Thread(target=self.serve, daemon=True)
|
||||||
|
|
||||||
|
def serve(self):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
data, addr = self.sock.recvfrom(65536)
|
||||||
|
except OSError:
|
||||||
|
return
|
||||||
|
if len(data) >= 12:
|
||||||
|
self.sock.sendto(self.reply(data), addr)
|
||||||
|
|
||||||
|
def reply(self, query):
|
||||||
|
if self.rcode:
|
||||||
|
return (query[:2] + struct.pack("!HHHHH", 0x8180 | self.rcode, 1, 0, 0, 0)
|
||||||
|
+ query[12:])
|
||||||
|
name = b""
|
||||||
|
pos = 12
|
||||||
|
while query[pos]:
|
||||||
|
name += query[pos + 1:pos + 1 + query[pos]] + b"."
|
||||||
|
pos += query[pos] + 1
|
||||||
|
name = name[:-1]
|
||||||
|
answer = self.records.get(name)
|
||||||
|
if not answer:
|
||||||
|
return (query[:2] + struct.pack("!HHHHH", 0x8183, 1, 0, 0, 0)
|
||||||
|
+ query[12:])
|
||||||
|
return (query[:2] + struct.pack("!HHHHH", 0x8180, 1, 1, 0, 0) + query[12:]
|
||||||
|
+ b"\xc0\x0c" + struct.pack("!HHIH", 1, 1, 60, 4)
|
||||||
|
+ socket.inet_aton(answer))
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
self.thread.start()
|
||||||
|
return self.port
|
||||||
|
|
||||||
|
|
||||||
|
def run(t):
|
||||||
|
broken = DnsServer(1, {}).start()
|
||||||
|
good = DnsServer(0, {b"here.test": "127.0.0.1"}).start()
|
||||||
|
|
||||||
|
# the destination the resolved name points at: a one-page origin
|
||||||
|
origin = t.free_port()
|
||||||
|
page = t.raw_server(origin, b"HTTP/1.1 200 OK\r\nContent-Length: 2\r\n"
|
||||||
|
b"\r\nok", close_after=True)
|
||||||
|
|
||||||
|
proxy = t.free_port()
|
||||||
|
t.start("nsfailover", f"""
|
||||||
|
log
|
||||||
|
flush
|
||||||
|
nserver 127.0.0.1:{broken}
|
||||||
|
nserver 127.0.0.1:{good}
|
||||||
|
auth iponly
|
||||||
|
allow *
|
||||||
|
proxy -p{proxy}
|
||||||
|
""", ports=[origin, proxy])
|
||||||
|
|
||||||
|
url = f"http://here.test:{origin}/"
|
||||||
|
t.eq(200, t.http(url, proxy=f"127.0.0.1:{proxy}").status,
|
||||||
|
"a name one server breaks is resolved by the next one")
|
||||||
|
|
||||||
|
r = t.http(f"http://gone.test:{origin}/", proxy=f"127.0.0.1:{proxy}")
|
||||||
|
t.ne(200, r.status if r else 0,
|
||||||
|
"a name the last server says is not there does not resolve")
|
||||||
|
|
||||||
|
page()
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
"""The radius command: a server may be a name, an address, and carry a
|
||||||
|
port, with an IPv6 address in brackets.
|
||||||
|
|
||||||
|
The port was in the man page but not in the code before: a server with a
|
||||||
|
port was simply refused. A name is resolved when the configuration is
|
||||||
|
read, with the name servers in force or the system's.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def run(t):
|
||||||
|
def accepted(config):
|
||||||
|
out = t.run_config("radius_cmd", config + "\nnot_a_command\n")
|
||||||
|
return "'radius' failed" not in out, out
|
||||||
|
|
||||||
|
ok, out = accepted("log\nradius s3cret 127.0.0.1:18120")
|
||||||
|
if ok:
|
||||||
|
t.ok("a server address with a port is accepted")
|
||||||
|
else:
|
||||||
|
t.fail("a server address with a port is accepted",
|
||||||
|
"'radius' not refused", out)
|
||||||
|
|
||||||
|
ok, out = accepted("log\nradius s3cret localhost")
|
||||||
|
if ok:
|
||||||
|
t.ok("a server name is accepted, resolved when the file is read")
|
||||||
|
else:
|
||||||
|
t.fail("a server name is accepted, resolved when the file is read",
|
||||||
|
"'radius' not refused", out)
|
||||||
|
|
||||||
|
if t.has_ipv6():
|
||||||
|
ok, out = accepted("log\nradius s3cret [::1]:18120")
|
||||||
|
if ok:
|
||||||
|
t.ok("an IPv6 server address in brackets, with a port, is accepted")
|
||||||
|
else:
|
||||||
|
t.fail("an IPv6 server address in brackets, with a port, is accepted",
|
||||||
|
"'radius' not refused", out)
|
||||||
|
|
||||||
|
out = t.run_config("radius_bad",
|
||||||
|
"log\nradius s3cret 999.999.999.999\nnot_a_command\n")
|
||||||
|
t.contains(out, "'radius' failed",
|
||||||
|
"an address that is none is refused")
|
||||||
|
t.not_contains(out, "'not_a_command'",
|
||||||
|
"and the file stops at the refused line")
|
||||||
Reference in new issue
Block a user