Compare commits

...
14 Commits
Author SHA1 Message Date
Vladimir Dubrovin 7959e0f358 dnspr: a name server's answer with no records relayed as it is (#1292)
C/C++ CI Linux / ubuntu-24.04-arm (push) Waiting to run
C/C++ CI Linux / ubuntu-latest (push) Waiting to run
C/C++ CI MacOS / macos-15 (push) Waiting to run
C/C++ CI Windows / windows-2022 (push) Waiting to run
C/C++ CI cmake / macos-15 (push) Waiting to run
C/C++ CI cmake / ubuntu-24.04-arm (push) Waiting to run
C/C++ CI cmake / ubuntu-latest (push) Waiting to run
C/C++ CI cmake / windows-2022 (push) Waiting to run
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Waiting to run
2026-11-26 15:50:24 +03:00
Vladimir Dubrovin fdd9f63222 tlspr: the SNI break split sent once the destination is connected 2026-11-26 15:39:18 +03:00
Vladimir Dubrovin 34e1fabf11 radius: a server may be a name, and the port is taken as written (#1027)
Update version files / version (push) Canceled after 0s
C/C++ CI Linux / ubuntu-24.04-arm (push) Canceled after 0s
C/C++ CI Linux / ubuntu-latest (push) Canceled after 0s
C/C++ CI Windows / windows-2022 (push) Canceled after 0s
C/C++ CI cmake / macos-15 (push) Canceled after 0s
C/C++ CI cmake / ubuntu-24.04-arm (push) Canceled after 0s
C/C++ CI cmake / ubuntu-latest (push) Canceled after 0s
C/C++ CI cmake / windows-2022 (push) Canceled after 0s
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Canceled after 0s
C/C++ CI MacOS / macos-15 (push) Canceled after 0s
The port was promised by the man page but never parsed: a server
address with a port was refused, and only the default 1812 could be
used. The address is parsed with parsehost() now, as nserver and
authnserver are, so a name is resolved when the configuration is read,
an IPv6 address may be written in brackets, and the port is the one
authentication is asked on, the accounting of the same server going to
the port after it. The man page says which name servers resolve the
name.
2026-11-21 14:45:06 +03:00
Vladimir Dubrovin 3f6755f7fc resolve: a name server answering with an error asks the next one (#735)
A reply with no answers and an error code - FORMERR, SERVFAIL, NOTIMP,
REFUSED - ended the resolution as if the name had no address, and the
servers after the one that answered were never asked, so one broken
server made every name it broke fail. Such an answer is passed over for
the next server now; a reply without data, and one that says the name is
not there, still end the search.
2026-11-21 13:59:48 +03:00
github-actions[bot] 2a51e0d8d5 Update version files for 0.9.9.4 2026-11-21 09:18:43 +00:00
Vladimir Dubrovin 4cd22ab6cd push as 0.9.9.4 2026-11-21 12:17:54 +03:00
Vladimir Dubrovin 4f7a611cbe socks: a SOCKS4a request is not a connect to the null address
C/C++ CI MacOS / macos-15 (push) Canceled after 0s
C/C++ CI Linux / ubuntu-24.04-arm (push) Canceled after 0s
C/C++ CI Linux / ubuntu-latest (push) Canceled after 0s
C/C++ CI Windows / windows-2022 (push) Canceled after 0s
C/C++ CI cmake / macos-15 (push) Canceled after 0s
C/C++ CI cmake / ubuntu-24.04-arm (push) Canceled after 0s
C/C++ CI cmake / ubuntu-latest (push) Canceled after 0s
C/C++ CI cmake / windows-2022 (push) Canceled after 0s
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Canceled after 0s
2026-11-18 21:37:33 +03:00
Vladimir Dubrovin 6b3a0f83fb auth: the pre-authorization of a UDP ASSOCIATE is not cached 2026-11-18 20:51:22 +03:00
Vladimir Dubrovin 1772ded781 socks: a UDP association is not relayed direct when its parent fails 2026-11-18 20:51:06 +03:00
Vladimir Dubrovin 4f4862e2c1 socks: a host name with control bytes or spaces is refused where it is read 2026-11-18 20:50:51 +03:00
Vladimir Dubrovin f105a27e68 smtpp: a login name of a port alone names no destination 2026-11-18 20:50:28 +03:00
Vladimir Dubrovin d82b780dda proxy: credentials of an earlier request not inherited by the next
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Has been cancelled
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Has been cancelled
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Has been cancelled
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Has been cancelled
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Has been cancelled
2026-11-13 17:51:09 +03:00
Vladimir Dubrovin 5aa3886eb8 tlspr: a ServerHello too short for the extensions length refused (#1286)
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Has been cancelled
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Has been cancelled
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Has been cancelled
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Has been cancelled
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Has been cancelled
2026-11-10 15:20:13 +03:00
Vladimir Dubrovin 15012177aa pcre: a rule with no ACL a match data of its own, not itself
A rule whose ACL was missing was handed to the filters as the
connection's data, which they read as a match data block and freed:
a pointer into the configuration, dereferenced as another type and
given back to malloc. A rule without an ACL now skips the check and
goes on with a block of its own, and nothing a filter is given is
ever the rule itself.

(cherry picked from commit a7e5a8b48b)
2026-11-08 14:42:34 +03:00
20 changed files with 142 additions and 60 deletions

No files matched your search

+9 -11
View File
@@ -1,12 +1,10 @@
3proxy-0.9.9.3 Released November, 7 2026 3proxy-0.9.9.4 Released November, 21 2026
! Fix: RADIUS authentication: the reply digest copied the shared secret right after the received bytes, so a reply of 4100 bytes with a secret of 17 or more characters wrote up to 47 bytes of it past the reply buffer on the stack, before the reply was authenticated; the digest is hashed over the reply and the secret in place now, with nothing written past the reply, and a reply is taken only from the address and port of the server the request went to, with the request's identifier and length, which was never checked before ! Fix: socks: a SOCKS4a request was refused as a connect to the null address, although in SOCKS4a the null address means that the destination is the name which follows it
! Fix: the PTR answer of a name server could write past the answer buffer on the stack: the label walk ran to the end of the whole message instead of the end of the record's data and could take a compression pointer for a label length (an answer of 3841 bytes or more reached past the buffer itself); the walk now stops at the end of the record's data, and a compressed, empty or truncated name is not accepted ! Fix: auth: a UDP ASSOCIATE is pre-authorized without looking at the destination its rules depend on, so its verdict holds for that association alone and is not kept for later requests
! Fix: every connection matching a pcre: (or regex:) rule matched on the one match data block of the rule, which pcre2_match() writes into: two connections matching at the same time raced and corrupted memory, bringing the process down under load; a connection now makes a match data block of its own ! Fix: socks: a UDP association was relayed direct when its parent failed, although the rules demanded the parent; it is refused now
! Fix: TLS: a read which could only be done once a write was, or a write once a read was (a TLS 1.3 key update answered while the socket cannot take more, for example), ended the connection with an error; each TLS socket remembers now what its pending read and write wait for, and the poll of the TLS layer waits for that ! Fix: socks: a host name with control bytes or spaces in it was taken as it stood; it is refused where it is read now
! Fix: Windows: a TLS read or write which wanted the socket again was not seen as one and dropped the connection with an unrelated error: the C library's errno was set where the socket error is read ! Fix: smtpp: a login name of a port alone, without a host, set the port but named no destination to connect to; such a login is refused now
! Fix: a client of a connect back (-R) service stayed in accept() for the connection another client of the same service took, until the next one came, past its time out and through a configuration reload; the connect back socket is non-blocking now, and an accept() with nothing to take does not count as one of the client's tries ! Fix: proxy: the credentials of an earlier request on a kept-alive connection decided for the requests after it; every request is authorized by its own credentials now
! Fix: ftppr: the answer of a server which logs in on USER alone (230, as anonymous FTP often does) or refuses the login was read but never handed to the client, which was left waiting for the answer to its PASS until the time out (#1284) ! Fix: tlspr: a TLS ServerHello too short for the extensions length it declared was read past its end; it is refused now (#1286)
! Fix: plugins: StringsPlugin, cutting a string table line at its end, wrote NULs past the line, into what the buffer kept of longer lines read before or past its end; FilePlugin passed the TLS state of the connection where the client's parameters were expected, so sending a string table over a TLS connection read a TLS state as a clientparam ! Fix: pcre: a rule with no ACL was handed to the filters as the connection's data, which they read as a match data block and freed: a pointer into the configuration, dereferenced as another type and given back to malloc; a rule without an ACL now skips the check and goes on with a block of its own
+ -B (for TCP services but admin) splits the TLS ClientHello passed through tlspr in the middle of the server name (SNI), so DPI systems which do not reassemble it do not see the host name; use it with -ocTCP_NODELAY -osTCP_NODELAY, or the kernel may join the segments again; -s keeps the same effect where -s is not splice (#1283)
+ An outgoing connection bound to an external address is bound with IP_BIND_ADDRESS_NO_PORT on Linux 4.2 and later: the port is chosen by connect() for the pair with the destination, so ports in use towards other destinations or closing in TIME_WAIT do not run the ephemeral range out; bind() no longer failed with result 12 or searched long for a port under many connections
+9 -11
View File
@@ -1,12 +1,10 @@
3proxy-0.9.9.3 Вышел 7 Ноября 2026 3proxy-0.9.9.4 Вышел 21 Ноября 2026
! Исправление: аутентификация RADIUS: дайджест ответа копировал общий секрет сразу за принятыми байтами, так что ответ размером 4100 байт с секретом в 17 и более символов записывал до 47 байт секрета за буфер ответа на стеке, ещё до проверки подлинности ответа; дайджест теперь вычисляется по ответу и секрету на месте, ничего не записывая за буфер, а ответ принимается только с адреса и порта сервера, которому был адресован запрос, с совпадающими с запросом идентификатором и длиной: раньше отправитель ответа не проверялся вовсе ! Исправление: socks: запрос SOCKS4a отвергался как соединение с нулевым адресом, хотя в SOCKS4a нулевой адрес означает, что назначение — имя, следующее за ним
! Исправление: ответ PTR от сервера имён мог записать данные за буфер ответа на стеке: обход имён шёл до конца всего сообщения вместо конца данных записи и мог принять байт-указатель сжатия за длину метки (ответ размером 3841 байт и более выходил за сам буфер); теперь обход останавливается в конце данных записи, а сжатое, пустое или обрезанное имя не принимается ! Исправление: auth: UDP ASSOCIATE проходит предварительную авторизацию, не зная назначения, от которого зависят её правила, поэтому её вердикт относится только к этой ассоциации и не сохраняется для последующих запросов
! Исправление: каждое соединение, проверяемое правилом pcre: (или regex:), сопоставлялось с единственным блоком данных сопоставления правила, в который пишет pcre2_match(): два соединения, сопоставляемые одновременно, конкурировали за него и портили память, приводя процесс к падению под нагрузкой; теперь каждое соединение получает собственный блок данных сопоставления ! Исправление: socks: UDP-ассоциация передавалась напрямую при сбое родителя, хотя правила требовали родителя; теперь она отвергается
! Исправление: TLS: чтение, возможное только после записи, или запись только после чтения (например, когда TLS 1.3 отвечает на обновление ключей, а сокет больше не принимает данные) завершало соединение с ошибкой; каждый TLS-сокет теперь помнит, чего ждут его незавершённые чтение и запись, и poll() TLS-уровня ждёт именно этого ! Исправление: socks: имя хоста с управляющими байтами или пробелами принималось как есть; теперь оно отвергается там, где читается
! Исправление: Windows: чтение или запись TLS, требующая повторного обращения к сокету, не распознавалась, и соединение завершалось с посторонней ошибкой: в месте чтения ошибки сокета устанавливалась ошибка libc (errno) ! Исправление: smtpp: имя входа из одного порта, без хоста, задавало порт, но не называло назначения для соединения; такое имя входа теперь отвергается
! Исправление: клиент обратного соединения (connect back, -R) оставался в accept() в ожидании соединения, которое забрал другой клиент той же службы, до следующего соединения, переживая свой тайм-аут и перезагрузку конфигурации; сокет обратного соединения теперь неблокирующий, и accept() без соединения не считается попыткой клиента ! Исправление: proxy: учётные данные раннего запроса в сохранённом соединении решали и для последующих запросов; теперь каждый запрос авторизуется своими учётными данными
! Исправление: ftppr: ответ сервера, входящего по одному USER (230, как часто бывает у анонимного FTP) или отказывающего во входе, прочитывался, но не передавался клиенту, который оставался ждать ответа на свой PASS до тайм-аута (#1284) ! Исправление: tlspr: ServerHello TLS, слишком короткий для объявленной длины расширений, читался за его концом; теперь он отвергается (#1286)
! Исправление: плагины: StringsPlugin, обрезая строку таблицы строк на её конце, записывал NUL за строкой, в остатки в буфере от прочитанных раньше более длинных строк или за его конец; FilePlugin передавал в socksend() состояние TLS соединения вместо параметров клиента, и отправка таблицы строк по TLS-соединению читала состояние TLS как clientparam ! Исправление: pcre: правило без ACL передавалось фильтрам как данные соединения, и они читали его как блок данных сопоставления и освобождали: указатель в конфигурацию, разыменованный как другой тип и возвращённый malloc; теперь правило без ACL пропускает проверку и идёт со своим блоком
+ -B (для TCP-служб, кроме admin) разбивает проходящий через tlspr ClientHello TLS посередине имени сервера (SNI), чтобы системы DPI, не собирающие его заново, не видели имя хоста; использовать вместе с -ocTCP_NODELAY -osTCP_NODELAY, иначе ядро может снова склеить сегменты; -s сохраняет тот же эффект там, где -s не означает splice (#1283)
+ Исходящее соединение, привязываемое к внешнему адресу, на Linux 4.2 и новее привязывается с IP_BIND_ADDRESS_NO_PORT: порт выбирает connect() для пары с адресом назначения, поэтому порты, занятые соединениями к другим адресам или закрывающиеся в TIME_WAIT, больше не исчерпывают эфемерный диапазон; bind() больше не завершался с результатом 12 при большом числе соединений и не тратил миллисекунды на поиск порта
+1 -1
View File
@@ -1 +1 @@
0.9.9.3 0.9.9.4
+6
View File
@@ -1,3 +1,9 @@
3proxy (0.9.9.4-1) buster; urgency=medium
*3proxy 0.9.9.4 initial build
-- z3APA3A <3apa3a@3proxy.org> Sat, 21 Nov 2026 09:18:43 +0000
3proxy (0.9.9.3-1) buster; urgency=medium 3proxy (0.9.9.3-1) buster; urgency=medium
*3proxy 0.9.9.3 initial build *3proxy 0.9.9.3 initial build
+8
View File
@@ -0,0 +1,8 @@
! Fix: socks: a SOCKS4a request was refused as a connect to the null address, although in SOCKS4a the null address means that the destination is the name which follows it
! Fix: auth: a UDP ASSOCIATE is pre-authorized without looking at the destination its rules depend on, so its verdict holds for that association alone and is not kept for later requests
! Fix: socks: a UDP association was relayed direct when its parent failed, although the rules demanded the parent; it is refused now
! Fix: socks: a host name with control bytes or spaces in it was taken as it stood; it is refused where it is read now
! Fix: smtpp: a login name of a port alone, without a host, set the port but named no destination to connect to; such a login is refused now
! Fix: proxy: the credentials of an earlier request on a kept-alive connection decided for the requests after it; every request is authorized by its own credentials now
! Fix: tlspr: a TLS ServerHello too short for the extensions length it declared was read past its end; it is refused now (#1286)
! Fix: pcre: a rule with no ACL was handed to the filters as the connection's data, which they read as a match data block and freed: a pointer into the configuration, dereferenced as another type and given back to malloc; a rule without an ACL now skips the check and goes on with a block of its own
+7 -2
View File
@@ -493,7 +493,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,
@@ -517,7 +520,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:
+1 -1
View File
@@ -1,5 +1,5 @@
Name: 3proxy Name: 3proxy
Version: 0.9.9.3 Version: 0.9.9.4
Release: 1%{?dist} Release: 1%{?dist}
Summary: 3proxy tiny proxy server Summary: 3proxy tiny proxy server
License: GPL/LGPL/Apache/BSD License: GPL/LGPL/Apache/BSD
+4 -1
View File
@@ -118,7 +118,10 @@ int doauth(struct clientparam * param){
if(authfuncs->authorize && if(authfuncs->authorize &&
(res = (*authfuncs->authorize)(param))) (res = (*authfuncs->authorize)(param)))
return res; return res;
if(param->srv->authcachetype && authfuncs->authenticate && authfuncs->authenticate != cacheauth && param->username && (!(param->srv->authcachetype&4) || (!param->pwtype && param->password))){ /* A UDP ASSOCIATE is pre-authorized without looking at the
destination its rules depend on, so its verdict holds for
that association alone and is not kept for later requests. */
if(param->srv->authcachetype && param->preauth != 1 && authfuncs->authenticate && authfuncs->authenticate != cacheauth && param->username && (!(param->srv->authcachetype&4) || (!param->pwtype && param->password))){
struct authcache ac={.username=""}; struct authcache ac={.username=""};
if(param->username) { if(param->username) {
+18
View File
@@ -569,11 +569,26 @@ int parsehost(int family, unsigned char *host, struct sockaddr *sa){
return ret; return ret;
} }
/* A host name is written into the request lines of parent protocols and
matched against rules, so a control byte or a space in it could end a
line early or pose as another destination. A name carrying one is
refused where it is read, and every name a client sends is read on
its way to the field. */
int badhostname(const char *hostname){
const unsigned char *c;
if(!hostname) return 1;
for(c = (const unsigned char *)hostname; *c; c++)
if(*c <= ' ' || *c == 0x7f) return 1;
return 0;
}
int parsehostname(char *hostname, struct clientparam *param, uint16_t port){ int parsehostname(char *hostname, struct clientparam *param, uint16_t port){
char *sp=NULL,*se=NULL; char *sp=NULL,*se=NULL;
int ret = 0; int ret = 0;
if(!hostname || !*hostname)return 2; if(!hostname || !*hostname)return 2;
if(badhostname(hostname)) return 1;
if(*hostname == '[') se=strchr(hostname, ']'); if(*hostname == '[') se=strchr(hostname, ']');
if ((sp = strchr(se?se:hostname, ':'))) { if ((sp = strchr(se?se:hostname, ':'))) {
if(strchr(sp+1, ':'))sp = NULL; if(strchr(sp+1, ':'))sp = NULL;
@@ -587,6 +602,9 @@ int parsehostname(char *hostname, struct clientparam *param, uint16_t port){
port = atoi(sp+1); port = atoi(sp+1);
*sp = ':'; *sp = ':';
} }
/* A port alone overrides the port of a host already set; without
one it names no destination to connect to. */
if(!param->hostname || !*param->hostname) return 1;
*SAPORT(&param->req) = htons(port); *SAPORT(&param->req) = htons(port);
return 0; return 0;
} }
+2 -2
View File
@@ -1456,8 +1456,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
View File
@@ -222,12 +222,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 *)&param->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 *)&param->sincr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
} RETURN(822);
RETURN(0);
} }
RETURN(0);
} }
if(!ip) { if(!ip) {
+7 -6
View File
@@ -264,13 +264,14 @@ static FILTER_ACTION pcre_filter_client(void *fo, struct clientparam * param, vo
struct pcre_filter_data *rule = (struct pcre_filter_data *)fo; struct pcre_filter_data *rule = (struct pcre_filter_data *)fo;
struct pcre_client_data *pcd; struct pcre_client_data *pcd;
*fc = fo; *fc = NULL;
if(!fo) return PASS; if(!fo) return PASS;
if(!rule->acl) return CONTINUE; if(rule->acl){
memset (&tmpace, 0, sizeof(struct ace)); memset (&tmpace, 0, sizeof(struct ace));
tmpace.src = rule->acl->src; tmpace.src = rule->acl->src;
res = pl->ACLMatches(&tmpace, param); res = pl->ACLMatches(&tmpace, param);
if(!res) return PASS; if(!res) return PASS;
}
/* the connection goes on with a match data of its own */ /* the connection goes on with a match data of its own */
if(!(pcd = pl->mallocfunc(sizeof(struct pcre_client_data)))){ if(!(pcd = pl->mallocfunc(sizeof(struct pcre_client_data)))){
*fc = NULL; *fc = NULL;
+21
View File
@@ -314,6 +314,27 @@ for(;;){
clhdrofs_req = -1; clhdrofs_req = -1;
param->nolongdatfilter = 0; param->nolongdatfilter = 0;
/* What the request brought belongs to it alone. A connection can carry
a request after another's, so the credentials of an earlier request
decide nothing for this one. */
if(param->username){
free(param->username);
param->username = NULL;
}
if(param->password){
free(param->password);
param->password = NULL;
}
param->pwtype = 0;
if(param->extusername){
free(param->extusername);
param->extusername = NULL;
}
if(param->extpassword){
free(param->extpassword);
param->extpassword = NULL;
}
if(keepalive && (param->cliinbuf == param->clioffset) && (param->remsock != INVALID_SOCKET)){ if(keepalive && (param->cliinbuf == param->clioffset) && (param->remsock != INVALID_SOCKET)){
memset(fds, 0, sizeof(fds)); memset(fds, 0, sizeof(fds));
+1
View File
@@ -335,6 +335,7 @@ void hashdelete(struct hashtable *ht, void* name);
int hashresolv(struct hashtable *ht, void* name, void* value, uint32_t *ttl); int hashresolv(struct hashtable *ht, void* name, void* value, uint32_t *ttl);
int parsehost(int family, unsigned char *host, struct sockaddr *sa); int parsehost(int family, unsigned char *host, struct sockaddr *sa);
int badhostname(const char *hostname);
int parsehostname(char *hostname, struct clientparam *param, uint16_t port); int parsehostname(char *hostname, struct clientparam *param, uint16_t port);
int parseusername(char *username, struct clientparam *param, int extpasswd); int parseusername(char *username, struct clientparam *param, int extpasswd);
int parseconnusername(char *username, struct clientparam *param, int extpasswd, uint16_t port); int parseconnusername(char *username, struct clientparam *param, int extpasswd, uint16_t port);
+7 -1
View File
@@ -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++) {
} }
+4
View File
@@ -195,6 +195,10 @@ void * smtppchild(struct clientparam* param) {
} }
} }
/* A login has to end with a host to connect to: what follows reads the
host name, and without one there is nowhere to go. */
if(!param->hostname || !param->extusername){RETURN(669);}
#ifndef WITHMAIN #ifndef WITHMAIN
{ {
int action, reqbufsize, reqsize; int action, reqbufsize, reqsize;
+6 -1
View File
@@ -119,7 +119,10 @@ void * sockschild(struct clientparam* param) {
} }
res = socks5_setaddr(param->srv->family, c, buf, &param->req); res = socks5_setaddr(param->srv->family, c, buf, &param->req);
if(res == 1) {RETURN(997);} if(res == 1) {RETURN(997);}
if(res == 2 && command == 1) {RETURN(431);} /* The null address is no destination to connect to, except in
SOCKS4a, where it says that the destination is the name which
follows it. */
if(res == 2 && ver == 5 && command == 1) {RETURN(431);}
param->sinsr = param->req; param->sinsr = param->req;
myinet_ntop(*SAFAMILY(&param->sinsr), SAADDR(&param->sinsr), (char *)buf, 64); myinet_ntop(*SAFAMILY(&param->sinsr), SAADDR(&param->sinsr), (char *)buf, 64);
break; break;
@@ -137,6 +140,7 @@ void * sockschild(struct clientparam* param) {
default: default:
RETURN(997); RETURN(997);
} }
if(badhostname((char *)buf)) {RETURN(21);}
if(param->hostname)free(param->hostname); if(param->hostname)free(param->hostname);
param->hostname = (unsigned char *)strdup((char *)buf); param->hostname = (unsigned char *)strdup((char *)buf);
if(!param->hostname){RETURN(21);} if(!param->hostname){RETURN(21);}
@@ -159,6 +163,7 @@ void * sockschild(struct clientparam* param) {
param->service = S_SOCKS45; param->service = S_SOCKS45;
if(sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]) < 0) {RETURN(441);} if(sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]) < 0) {RETURN(441);}
buf[127] = 0; buf[127] = 0;
if(badhostname((char *)buf)) {RETURN(21);}
if(param->hostname)free(param->hostname); if(param->hostname)free(param->hostname);
param->hostname = (unsigned char *)strdup((char *)buf); param->hostname = (unsigned char *)strdup((char *)buf);
if(!param->hostname){RETURN(21);} if(!param->hostname){RETURN(21);}
+14 -10
View File
@@ -224,6 +224,7 @@ int parsehello(int type, unsigned char *hello, unsigned len, char *sni, int * sn
else if(type == 2){ else if(type == 2){
offset += 3; offset += 3;
} }
if((offset + 2) > len) return -6;
elen = size16(hello+offset); elen = size16(hello+offset);
offset += 2; offset += 2;
if(elen+offset != len) return -9; if(elen+offset != len) return -9;
@@ -334,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 : param->srv->srvstarttls; PROXYSERVICE stlsproto = param->clientstarttls? param->clientstarttls : param->srv->srvstarttls;
if(!param->clientstarttls && stlsproto){ if(!param->clientstarttls && stlsproto){
@@ -356,16 +358,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);
} }
@@ -385,6 +378,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){
+8 -4
View File
@@ -158,8 +158,10 @@ static void udpreset(struct clientparam *param)
/* /*
* Authorize param->req and (re)build the server side of the association: * Authorize param->req and (re)build the server side of the association:
* a parent proxy chain and/or an external address may be selected by the ACL. * a parent proxy chain and/or an external address may be selected by the ACL.
* Returns the authorization result. param->remsock is INVALID_SOCKET if the * Returns the authorization result. param->remsock is INVALID_SOCKET when
* socket can not be created, in this case the association can not continue. * the authorization refused the association or the socket can not be
* created; the association can not continue then, so that a parent the
* rules demand is never quietly replaced by a direct relay.
*/ */
static int udpreconnect(struct clientparam *param) static int udpreconnect(struct clientparam *param)
{ {
@@ -185,9 +187,10 @@ static int udpreconnect(struct clientparam *param)
param->remsock = INVALID_SOCKET; param->remsock = INVALID_SOCKET;
} }
udpreset(param); udpreset(param);
return res;
} }
if (udpbind(param)) return res? res : 11; if (udpbind(param)) return 11;
return res; return 0;
} }
int udpsockmap(struct clientparam *param, int timeo) int udpsockmap(struct clientparam *param, int timeo)
@@ -277,6 +280,7 @@ int udpsockmap(struct clientparam *param, int timeo)
if (len < 7 + sz) return 485; if (len < 7 + sz) return 485;
memcpy(dstnamebuf, base + 5, sz); memcpy(dstnamebuf, base + 5, sz);
dstnamebuf[sz] = 0; dstnamebuf[sz] = 0;
if (badhostname(dstnamebuf)) continue;
dstname = dstnamebuf; dstname = dstnamebuf;
i = 5 + sz; i = 5 + sz;
if (!getip46(param->srv->family, (unsigned char *)dstnamebuf, if (!getip46(param->srv->family, (unsigned char *)dstnamebuf,
+4 -4
View File
@@ -1,14 +1,14 @@
#ifndef VERSION #ifndef VERSION
#define VERSION "3proxy-0.9.9.3" #define VERSION "3proxy-0.9.9.4"
#endif #endif
#ifndef BUILDDATE #ifndef BUILDDATE
#define BUILDDATE "261107091432" #define BUILDDATE "261121091843"
#endif #endif
#define MAJOR3PROXY 0 #define MAJOR3PROXY 0
#define SUBMAJOR3PROXY 9 #define SUBMAJOR3PROXY 9
#define MINOR3PROXY 9 #define MINOR3PROXY 9
#define SUBMINOR3PROXY 3 #define SUBMINOR3PROXY 4
#define RELEASE3PROXY "3proxy-0.9.9.3(" BUILDDATE ")\0" #define RELEASE3PROXY "3proxy-0.9.9.4(" BUILDDATE ")\0"
#ifndef YEAR3PROXY #ifndef YEAR3PROXY
#define YEAR3PROXY "2026" #define YEAR3PROXY "2026"
#endif #endif