Skip to content

Commit

Permalink
refactor it all
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolay-ngrok committed Sep 28, 2023
1 parent f317a90 commit 664dde9
Show file tree
Hide file tree
Showing 44 changed files with 2,165 additions and 2,281 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ngrok.net;

import com.ngrok.Tunnel;
import com.ngrok.Listener;

import java.io.IOException;
import java.net.ServerSocket;
Expand All @@ -10,15 +10,15 @@
/**
* A server socket for accepting connections to an ngrok tunnel.
*/
public class TunnelServerSocket extends ServerSocket {
public class ListenerServerSocket extends ServerSocket {
/**
* Creates a new server socket for the given tunnel.
*
* @param tunnel the tunnel to accept connections for
* @throws IOException if an I/O error occurs
*/
public TunnelServerSocket(Tunnel tunnel) throws IOException {
super(new TunnelSocketImpl(tunnel));
public ListenerServerSocket(Listener listener) throws IOException {
super(new ListenerSocketImpl(listener));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ngrok.net;

import com.ngrok.Tunnel;
import com.ngrok.Listener;

import java.io.IOException;
import java.net.SocketImpl;
Expand All @@ -9,16 +9,16 @@
* An implementation of the {@link AbstractSocketImpl} interface for
* establishing a connection to an ngrok tunnel.
*/
public class TunnelSocketImpl extends AbstractSocketImpl {
private final Tunnel tunnel;
public class ListenerSocketImpl extends AbstractSocketImpl {
private final Listener listener;

/**
* Creates a new tunnel socket implementation for the given tunnel.
*
* @param tunnel the tunnel to establish a connection to
*/
public TunnelSocketImpl(Tunnel tunnel) {
this.tunnel = tunnel;
public ListenerSocketImpl(Listener listener) {
this.listener = listener;
}

/**
Expand All @@ -30,6 +30,6 @@ public TunnelSocketImpl(Tunnel tunnel) {
@Override
protected void accept(SocketImpl s) throws IOException {
var csi = (ConnectionSocketImpl) s;
csi.setConnection(tunnel.accept());
csi.setConnection(listener.accept());
}
}
48 changes: 20 additions & 28 deletions ngrok-java-native/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ fn main() -> Result<(), Box<dyn Error>> {
Cow::from("com.ngrok.NativeSession"),
Cow::from("com.ngrok.NativeTcpListener"),
Cow::from("com.ngrok.NativeTcpForwarder"),
Cow::from("com.ngrok.NativeTlsTunnel"),
Cow::from("com.ngrok.NativeHttpTunnel"),
Cow::from("com.ngrok.NativeLabeledTunnel"),
Cow::from("com.ngrok.NativeTlsListener"),
Cow::from("com.ngrok.NativeTlsForwarder"),
Cow::from("com.ngrok.NativeHttpListener"),
Cow::from("com.ngrok.NativeHttpForwarder"),
Cow::from("com.ngrok.NativeEdgeListener"),
Cow::from("com.ngrok.NativeEdgeForwarder"),
Cow::from("com.ngrok.NativeEdgeConnection"),
Cow::from("com.ngrok.NativeEndpointConnection"),
];
Expand All @@ -33,31 +36,20 @@ fn main() -> Result<(), Box<dyn Error>> {
Cow::from("com.ngrok.Session$RestartCallback"),
Cow::from("com.ngrok.Session$UpdateCallback"),
Cow::from("com.ngrok.Session$HeartbeatHandler"),
Cow::from("com.ngrok.Tunnel"),
Cow::from("com.ngrok.Tunnel$Builder"),
Cow::from("com.ngrok.EndpointTunnel"),
Cow::from("com.ngrok.EndpointTunnel$Builder"),
Cow::from("com.ngrok.TlsTunnel"),
Cow::from("com.ngrok.TlsTunnel$Builder"),
Cow::from("com.ngrok.HttpTunnel"),
Cow::from("com.ngrok.HttpTunnel$Header"),
Cow::from("com.ngrok.HttpTunnel$BasicAuthOptions"),
Cow::from("com.ngrok.HttpTunnel$OAuthOptions"),
Cow::from("com.ngrok.HttpTunnel$OIDCOptions"),
Cow::from("com.ngrok.HttpTunnel$WebhookVerification"),
Cow::from("com.ngrok.HttpTunnel$Builder"),
Cow::from("com.ngrok.LabeledTunnel"),
Cow::from("com.ngrok.LabeledTunnel$Label"),
Cow::from("com.ngrok.LabeledTunnel$Builder"),
Cow::from("com.ngrok.Connection"),
Cow::from("com.ngrok.EdgeConnection"),
Cow::from("com.ngrok.EndpointConnection"),
Cow::from("com.ngrok.TunnelInfo"),
Cow::from("com.ngrok.EndpointInfo"),
Cow::from("com.ngrok.Listener"),
Cow::from("com.ngrok.Forwarder"),
Cow::from("com.ngrok.Tcp"),
Cow::from("com.ngrok.Tcp$Builder"),
Cow::from("com.ngrok.MetadataBuilder"),
Cow::from("com.ngrok.EdgeBuilder"),
Cow::from("com.ngrok.EdgeBuilder$Label"),
Cow::from("com.ngrok.EndpointBuilder"),
Cow::from("com.ngrok.HttpBuilder"),
Cow::from("com.ngrok.Http$Header"),
Cow::from("com.ngrok.Http$BasicAuth"),
Cow::from("com.ngrok.Http$OAuth"),
Cow::from("com.ngrok.Http$OIDC"),
Cow::from("com.ngrok.Http$WebhookVerification"),
Cow::from("com.ngrok.TcpBuilder"),
Cow::from("com.ngrok.TlsBuilder"),
Cow::from("com.ngrok.AbstractEdge"),
Cow::from("com.ngrok.AbstractEndpoint"),
];
let output_dir = PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR not set"));

Expand Down
Loading

0 comments on commit 664dde9

Please sign in to comment.