Skip to content

dragsbruh/postmistress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postmistress

tcp->websocket proxy

usage

NAME:
   postmistress serve

USAGE:
   postmistress serve

OPTIONS:
   --tcp-address string  address to bind to for incoming tcp requests [$TCP_ADDRESS]
   --tcp-target string    websocket server to forward tcp requests to [$TCP_TARGET]
   --ws-address string   address to bind to for websocket requests [$WS_ADDRESS]
   --auth string         auth string to forward to websocket and check for in incoming websocket requests [$AUTH]
   --help, -h            show help

tldr

  1. binds to tcp-address and accepts incoming tcp connections

    for every incoming tcp connection

    1. connects to ws-target over http websocket
    2. sends auth as Authorization header (if auth is set)
    3. joins tcp stream and websocket stream
  2. binds to ws-address and accepts incoming websocket connections

    for every incoming websocket connection to /connect?target=<tcp-target>

    1. rejects if auth is set and does not match Authorization header
    2. connects to tcp-target query parameter over tcp
    3. joins tcp stream and websocket stream

examples

  1. (tcp->ws) forwarding smtp address :25 to remote handler wss://my-ws-handler.com/handler

    you will obviously need to write the handler yourself

    TCP_ADDRESS=:25
    TCP_TARGET=wss://my-ws-handler.com/handler
    AUTH=mysecretpassword # important for security reasons, you must check for this in your handler
  2. (ws->tcp) forwarding to remote smtp server 1.2.3.4:25 from websocket server :8080

    WS_ADDRESS=:8080
    # AUTH=

    client must connect to ws://localhost:8080/connect?target=1.2.3.4:25 over websocket and provide AUTH in Authorization header if set.

  3. (hacky: tcp->tcp) forwarding smtp port :25 to remote smtp server 1.2.3.4:25

    WS_ADDRESS=:8080 # any available port is fine, as long as this matches port in `TCP_TARGET`
    TCP_ADDRESS=:25
    TCP_TARGET=ws://localhost:8080/connect?target=1.2.3.4:25
    # AUTH= # this wont do much here, tcp server forwards the same to websocket server which is checked to the same string

About

tcp<->ws proxy for mailservers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages