Skip to content

Conversation

@hanayashiki
Copy link

See commit messages for details.

Example use:

const AnyProxy = require('anyproxy');
const options = {
    port: 8001,
    rule: {
        beforeSendWsMessage: (e, url) => {
            console.log(url, e.data);
        },
        beforeReadWsMessage: (e, url) => {
            console.log(url, e.data);
        }
    },
    webInterface: {
        enable: true,
        webPort: 8002
    },
    throttle: 10000,
    forceProxyHttps: true,
    wsIntercept: true,
    silent: false,
    dangerouslyIgnoreUnauthorized: true,
};


const proxyServer = new AnyProxy.ProxyServer(options);


proxyServer.on('ready', () => { /* */
});
proxyServer.on('error', (e) => { /* */
});
proxyServer.start();


Output:

...
wss://example.com {"a": 0, "b": 1}
wss://example.com {"a": 1, "b": 2}
...

Chenyu Wang added 2 commits March 3, 2020 02:36
beforeReadWsMessage is passed with two parameters: [event: MessageEvent, wsUrl: string],
where `event` is passed from WebSocket.onmessage, and wsUrl is the connection's url.
beforeReadWsMessage is called after the message arrives and before the client reads it.
beforeSendWsMessage is similar to beforeSendWsMessage, passed with [event: MessageEvent, wsUrl: string].
@CLAassistant
Copy link

CLAassistant commented Mar 3, 2020

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants