Commit Graph

41 Commits

Author SHA1 Message Date
Soner Tari
d1a3328c58 Differentiate PassSite option from Passthrough option: PassSite does not require Passthrough now
Remove redundant if conditions
2019-05-02 19:06:48 +03:00
Soner Tari
c146b8a0ec Make sure sni and ssl_names are not null, fixes signal 11 crash reported by @janusloo 2019-05-01 00:35:15 +03:00
Soner Tari
c3abe74776 Add client filtering to PassSite option, per site filters can be defined using client IP addresses, users, and description keywords 2019-04-21 01:00:46 +03:00
Soner Tari
7e17bd198e Require ssl_names if passsite is set 2019-04-19 23:21:58 +03:00
Soner Tari
119fc8e69e Improve passsite log messages and comments 2019-04-19 20:59:28 +03:00
Soner Tari
7e8fcbcafa Move strncpy() call from passsite matching to initial PassSite setup 2019-04-19 04:21:41 +03:00
Soner Tari
ddeb9831ed Add PassSite option, if the site matches SNI or common names in the SSL certificate, the connection is passed through the proxy, issue #12 2019-04-19 01:17:41 +03:00
Soner Tari
24972bda48 Rearrange debug log messages 2019-04-03 20:23:30 +03:00
Soner Tari
ea532a9464 Update with sslsplit develop ssl ctx improvements 2019-03-26 15:54:42 +03:00
Soner Tari
040d00b546 Fix passthrough mode broken by the new pending ssl conns list: It is necessary to NULL the sslctx to prevent passthrough mode trying to access it (signal 11 crash)
Note that we cannot redirect failed ssl connections to login page while switching to passthrough mode
Remove now redundant pxy_fd_readcb() function
2019-03-24 15:57:03 +03:00
Soner Tari
ad38b68ad7 Fix a possible multithreading issue: Ignore event_add() failure and do not try to close the conn after adding it to pending ssl conns list
Debug print pending ssl conns list
Remove redundant asprintf() calls and vars
Rename fields and fix whitespace
2019-03-23 23:34:38 +03:00
Soner Tari
bf67b617c2 Keep track of ssl conns waiting for the first packet, and remove them if they time out
Otherwise if no packet arrives, hence readcb does not fire, that ssl conn is lost causing memory and fd leak
Accepting a connection does not mean that a packet will be received
Use better names
2019-03-22 15:21:39 +03:00
Soner Tari
dc788862a9 Reintroduce BEV_OPT_THREADSAFE flag, after a signal 10 crash involving buffer events
Rearrange and fix fd close locations and conn termination
2019-03-21 06:06:56 +03:00
Soner Tari
6f2cf92e51 Do not pass BEV_OPT_THREADSAFE flag to bufferevent new socket/filter functions anymore: Multithreading issues seems to be solved now 2019-03-19 17:17:57 +03:00
Soner Tari
cc0b94c17f Do not do anything with the conn ctx on the thrmgr thread after setting event callbacks and/or socket connect
Always lock conn thr while reading ctx fields, otherwise we may get wrong values
2019-03-18 03:59:40 +03:00
Soner Tari
844e68116a Move userauth from thrmgr thread to conn handling threads, and do not enable r/w callbacks until userauth succeeds
Lock conn thread instead of thrmgr thread while adding conns (giant thrmgr lock versus conn thread level locks), so add conn thread mutex and remove thrmgr mutex
Offload thrmgr thread by moving many conn related setup to conn handling threads
Fix signal 6 crash caused by calling pxy_thrmgr_timer_cb() while failed conn is being freed, so use conn thread mutexes and defer adding conn to thr conn list until conn setup succeeds
Other fixes, improvements, and clean-up
2019-03-14 03:47:03 +03:00
Soner Tari
2f3fda5367 Do not try to close conns on the thrmgr thread after setting event callbacks and/or socket connect
Use strncpy() instead of memcpy(), to limit max size with dest buffer
2019-03-13 17:11:54 +03:00
Soner Tari
7b11eb15fa Update copyright year to 2019 2019-03-13 14:42:40 +03:00
Soner Tari
56c3bdf5d8 Do not try to term/close conns on the thrmgr thread after setting event callbacks and/or socket connect 2019-03-12 19:36:30 +03:00
Soner Tari
96ecd8e4c3 Pass BEV_OPT_THREADSAFE to bufferevent_socket_new() and similar functions, otherwise if we are out of fds, we get signal 10 or 6 crashes sometimes, nothing else seems to work 2019-03-11 01:56:09 +03:00
Soner Tari
3a6f797917 Do not forget to reset sqlite stmt if userdb is busy or locked, otherwise we get stuck and go out of fds too
Check retval of event_add() calls
Reduce frequency of userdb atime updates by not updating until idle time reaches more than half of user timeout value, otherwise privsep server can get very busy causing locked userdb
Do not care about multiple matches of IP addresses in arp cache on OpenBSD either
Performance and code reuse improvements, simplifications
2019-03-10 04:26:00 +03:00
Soner Tari
70a22f4515 Do not break the event loop if out of fds, instead properly check all retvals of libevent functions
So remove getdtable*() solution
2018-11-30 02:49:37 +03:00
Soner Tari
d0687b3398 Fix double init of protoctx, memory leak
Free vars where they are allocated, always
2018-11-10 20:46:39 +03:00
Soner Tari
83468afb1f Fix ssl setup error handling, ssl ctx does not have any proto arg, so arg is always null at that point 2018-11-10 19:22:16 +03:00
Soner Tari
52d37297b6 Update with sslsplit develop changes, especially content logging
Change SIGHUP to behave like SIGUSR1
2018-11-03 18:23:31 +03:00
Soner Tari
12ecc96648 Assume co-ownership of refactored and new pxy and proto source files by adding copyright line below the original copyright line 2018-10-30 12:42:52 +03:00
Soner Tari
87eb6ce004 Move conn end free function callback to conn end struct, proto ctx should not keep track of such conn end details, conn end should know which function to be called to free itself, we may have different protos on different ends of the same conn
Improve and clean up
2018-10-29 21:38:42 +03:00
Soner Tari
8c7b8bafcf Fix build warning with LibreSSL 2.8.2, id is const now 2018-10-27 00:30:09 +03:00
Soner Tari
d4a209cbfb Avoid redundant void to ctx type casts by passing ctx explicitly 2018-10-23 00:18:48 +03:00
Soner Tari
e8e8071772 Defer conn free until the exit code of topmost callback functions, for both parent and child connections, this is necessary to handle error conditions correctly and terminate connections gracefully
So introduce term flags in ctx and replace free functions with term functions to raise the term flag, this approach enables us to terminate connection anywhere in the code without causing use after free crashes
Improve and clean up
2018-10-22 23:13:42 +03:00
Soner Tari
c085cafe0f Rename srv_dst to srvdst
Clean up
2018-10-22 16:12:07 +03:00
Soner Tari
adb99db518 Handle out of memory conditions correctly
Do not do anything else with ctx while returning from topmost callback functions if it is freed
Rename functions, improve, and clean up
2018-10-22 15:30:18 +03:00
Soner Tari
2f0e574f09 Fix autossl, but Evolution client sometimes does not send ehlo, especially after user rejects self-signed cert, which needs further investigation
And other improvements
2018-10-21 22:01:46 +03:00
Soner Tari
c91d569723 Improve debug logging, log proto name on connect/disconnect
Rename vars and functions
Improve and clean up
2018-10-21 00:25:01 +03:00
Soner Tari
1374d37722 Decouple stats from proto code
Move connect logging to the topmost callback functions, amap
Improve and clean up
2018-10-20 15:29:51 +03:00
Soner Tari
0c2d12f35d Decouple connect logging from proxy code
Improve and clean up
2018-10-20 02:03:21 +03:00
Soner Tari
3e0cbc2905 Rearrange and clean up 2018-10-19 15:03:36 +03:00
Soner Tari
59c11017bd Refactor to move common logging and stats code to topmost callback functions
Log only orig content in the topmost readcb
Improve and clean up
2018-10-19 01:31:10 +03:00
Soner Tari
13040639b7 Add static and NONNULL attrib
Rename, improve, and clean up
2018-10-18 02:00:49 +03:00
Soner Tari
f681b31497 Decouple ssl from tcp and other protocols
Improve and clean up
2018-10-17 16:28:21 +03:00
Soner Tari
0c55600ec7 Move ssl proto to its own file, but still needs more refactoring to decouple ssl from other protocols, especially tcp
Rename and clean up
2018-10-16 03:37:07 +03:00