diff options
author | cbdev <cb@cbcdn.com> | 2019-06-02 15:45:12 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2019-06-02 15:45:12 +0200 |
commit | edcec9fa9086599d56bffe7fdb2c1f05ae7a3ad8 (patch) | |
tree | 4e2bb02bbe8a2db9d4f217a664e73c25c37c7633 /websocksy.c | |
parent | b9297647c68c963a977e2c18f421211e24f9e85a (diff) | |
download | websocksy-edcec9fa9086599d56bffe7fdb2c1f05ae7a3ad8.tar.gz websocksy-edcec9fa9086599d56bffe7fdb2c1f05ae7a3ad8.tar.bz2 websocksy-edcec9fa9086599d56bffe7fdb2c1f05ae7a3ad8.zip |
File backend peer query
Diffstat (limited to 'websocksy.c')
-rw-r--r-- | websocksy.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/websocksy.c b/websocksy.c index c635ca7..7727ef0 100644 --- a/websocksy.c +++ b/websocksy.c @@ -125,12 +125,23 @@ static peer_transport client_detect_transport(char* host){ return peer_tcp_client; } +static char* client_detect_port(char* host){ + size_t u; + + for(u = 0; host[u]; u++){ + if(host[u] == ':'){ + host[u] = 0; + return strdup(host + u + 1); + } + } + + return NULL; +} + /* Establish peer connection for negotiated websocket */ int client_connect(websocket* ws){ ws->peer = config.backend.query(ws->request_path, ws->protocols, ws->protocol, ws->headers, ws->header, ws); if(!ws->peer.host){ - //TODO check port if network socket - //TODO try to extract port from host if none given //no peer provided return 1; } @@ -145,6 +156,15 @@ int client_connect(websocket* ws){ ws->peer.transport = client_detect_transport(ws->peer.host); } + if((ws->peer.transport == peer_tcp_client || ws->peer.transport == peer_udp_client) + && !ws->peer.port){ + ws->peer.port = client_detect_port(ws->peer.host); + if(!ws->peer.port){ + //no port provided + return 1; + } + } + //TODO connection establishment should be async in the future switch(ws->peer.transport){ case peer_tcp_client: @@ -172,6 +192,10 @@ int client_connect(websocket* ws){ return (ws->peer_fd == -1) ? 1 : 0; } +ws_framing core_framing(char* name){ + return plugin_framing(name); +} + /* Signal handler, attached to SIGINT */ static void signal_handler(int signum){ shutdown_requested = 1; |