Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customization of Netty Bootstrap and ChannelPipeline #1241

Merged
merged 2 commits into from Mar 23, 2024

Conversation

kevinherron
Copy link
Contributor

@kevinherron kevinherron commented Mar 23, 2024

This allows e.g. a SOCKS proxy to be configured fairly easily:

public static void main(String[] args) throws UaException {
  var client = OpcUaClient.create(
      "opc.tcp://milo.digitalpetri.com:62541/milo",
      endpoints -> endpoints.stream()
          .filter(e -> Objects.equals(e.getSecurityPolicyUri(), SecurityPolicy.None.getUri()))
          .findFirst(),
      tcb -> tcb.setChannelPipelineCustomizer(p -> addSocksProxyHandler(p)),
      ccb -> {}
  );

  client.connect();
}

private static void addSocksProxyHandler(ChannelPipeline pipeline) {
  var handler = new Socks5ProxyHandler(new InetSocketAddress("localhost", 1080));
  pipeline.addFirst(handler);
}

@kevinherron kevinherron marked this pull request as ready for review March 23, 2024 18:46
@kevinherron kevinherron merged commit 8d78458 into dev/1.0 Mar 23, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant