Skip to content

Commit

Permalink
Merge pull request #15 from atrifat/feat-max-payload-setting-support
Browse files Browse the repository at this point in the history
Max websocket payload setting support
  • Loading branch information
imksoo authored Aug 8, 2024
2 parents e8f2e99 + dbb4a86 commit a519cfc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ WHITELISTED_PUBKEYS=
FILTER_PROXY_EVENTS=
# Set true to enable forwarding of request headers to upstream server
ENABLE_FORWARD_REQ_HEADERS=false
# Set maximum websocket server payload size (maximum allowed message size) in bytes
MAX_WEBSOCKET_PAYLOAD_SIZE=1000000

# Regular expressions for content filtering. Each regular expression is stored as a separate environment variable.
# These regular expressions are used to match specific patterns in texts.
Expand Down
4 changes: 3 additions & 1 deletion filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const whitelistedPubkeys: string[] =
const filterProxyEvents = process.env.FILTER_PROXY_EVENTS === "true";
// Forward request headers to upstream
const enableForwardReqHeaders = process.env.ENABLE_FORWARD_REQ_HEADERS === "true";
// Set maximum websocket server payload size (maximum allowed message size) in bytes
const maxWebsocketPayloadSize: number = parseInt(process.env.MAX_WEBSOCKET_PAYLOAD_SIZE ?? "1000000");

// クライアントIPアドレスのCIDRフィルタ
const cidrRanges: string[] = Object.keys(process.env)
Expand Down Expand Up @@ -194,7 +196,7 @@ function listen(): void {
},
);
// WebSocketサーバーの構成
const wss = new WebSocket.Server({ server });
const wss = new WebSocket.Server({ server: server, maxPayload: maxWebsocketPayloadSize });
wss.on(
"connection",
async (downstreamSocket: WebSocket, req: http.IncomingMessage) => {
Expand Down

0 comments on commit a519cfc

Please sign in to comment.