chhsiao90 / nitmproxy

Proxy server based on netty
MIT License
151 stars 67 forks source link

nitmproxy v2.0.0 #111

Closed chhsiao90 closed 2 years ago

chhsiao90 commented 2 years ago
  1. Merge HttpListener and FowardListener into NitmProxyListener
  2. Initial support for response modification
  3. Add listener.onInit (called on channel first initialized)
  4. Add listener.onConnect (called on server channel connected)
  5. Add listener.close (called on channel closed, to provide the change for users to release the resources)
  6. Rename websocket functions to onWsRequest, onWsResonse (it's more clearly)
chhsiao90 commented 2 years ago

Hi @koh-osug @abbasvalliani

There is a lot of change in this pull request, can you help to check this? Any comments will be appreciated. Thanks.

There is also a lot of breaking change (I'm trying to make the interface and function name more readable and reasonable), so I already update the next release version to 2.0.0 as a major release. Sorry for the inconvenience about the breaking change.

chhsiao90 commented 2 years ago

@abbasvalliani

Example code for http response intercept can be found here

It looks complicated, I will create some template interceptors to simplify the intercept process in separate PR.

kaoh commented 2 years ago

Yes, I will check it. My setup is a local MITM proxy and an Android project.

abbasvalliani commented 2 years ago

@chhsiao90 My initial gut feeling looking at this is the level of complexity for the user. Any chance we can simplify this while still providing the control (if needed). I don't have an issue using the API as is, but could be cumbersome for someone new.

chhsiao90 commented 2 years ago

Thanks @abbasvalliani for the feedback, agreed with the complexity of the API. This PR just built the fundamental of response interception, will provide more user friendly api later!

kaoh commented 2 years ago

I have used:

  config.getListeners().add(NitmProxyListenerProvider.singleton(new NitmProxyListener() {
            @Override
            public void onConnect(ConnectionContext connectionContext, Channel serverChannel) {
                System.out.println("Connected");
            }
        }));

and the listener is triggered once the backend channel is established. But I'm confused about the API. I do not understand the singleton pattern, actually whenever the singleton method is called, a new instance is created? And a NitmProxyListenerProvider is used, not a listener directly.

chhsiao90 commented 2 years ago

To configure a listener provider instead of listener itself is because we want to have the flexibility to have different instance of listener across different context. The singleton method is to provide for the case if you just want to have only one instance in the server.

Karsten Ohme @.***>於 2021年10月22日 週五,下午8:34寫道:

I have used:

config.getListeners().add(NitmProxyListenerProvider.singleton(new NitmProxyListener() { @Override public void onConnect(ConnectionContext connectionContext, Channel serverChannel) { System.out.println("Connected"); } }));

and the listener is triggered once the backend channel is established. But I'm confused about the API. I do not understand the singleton pattern, actually whenever the singleton method is called, a new instance is created? And a NitmProxyListenerProvider is used, not a listener directly.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chhsiao90/nitmproxy/pull/111#issuecomment-949590127, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSLJWFSSTYWTZQPRMRV5HLUIFK6JANCNFSM5GLA5RWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

abbasvalliani commented 2 years ago

@chhsiao90 Thanks for all your hard work on this. Is there a way to prevent the Http2FrameWrapper from being part of the response interface and use Netty objects directly?

abbasvalliani commented 2 years ago

@chhsiao90 Any chance we can do a release of 2.0? Thanks!

chhsiao90 commented 2 years ago

nitmproxy v2.0.0 just released