Skip to content

Commit

Permalink
Export defaultConnectionHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
PondWader committed May 17, 2024
1 parent e995e50 commit ba4be13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/connectionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ export default function (connection: InitialisedSocks5Connection, sendStatus: (s
})

connection.socket.on('close', () => stream.destroy());

return stream;
}
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Socks5Server from "./Server";
import connectionHandler from "./connectionHandler";

type ServerOptions = {
auth?: {
Expand All @@ -14,11 +15,11 @@ export function createServer(opts?: ServerOptions) {

if (opts?.auth) server.setAuthHandler((conn) => {
return conn.username === opts.auth!.username && conn.password === opts.auth!.password
})
})

if (opts?.port) server.listen(opts.port, opts.hostname);

return server;
}

export { Socks5Server };
export { Socks5Server, connectionHandler as defaultConnectionHandler };

0 comments on commit ba4be13

Please sign in to comment.