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

TCP proxy ssh error #15

Open
losyn opened this issue Jul 26, 2023 · 0 comments
Open

TCP proxy ssh error #15

losyn opened this issue Jul 26, 2023 · 0 comments
Labels

Comments

@losyn
Copy link

losyn commented Jul 26, 2023

`
public class VpsVerticle extends AbstractVerticle {
private static final Map<String, Vps> vps = new ConcurrentHashMap<>();

@Override
public void start(Promise<Void> promise) {
    vertx.createNetServer().connectHandler(server -> {
        System.out.println("PTO: " + server.remoteAddress());
        vertx.createNetClient().connect(22, "192.168.10.211", event -> {
            if (event.succeeded()) {
                vps.put("xxxxx", new Vps(server, event.result()).proxy());
            } else {
                event.cause().printStackTrace();
            }
        });
    }).listen(10022, tcp -> {
        if (tcp.succeeded()) {
            System.out.println("proxy:10022");
            promise.complete();
        } else {
            promise.fail(tcp.cause());
        }
    });
}

}

public class Vps implements Serializable {
private static final long serialVersionUID = -4212035958492348735L;
private final NetSocket server,client;

public Vps(NetSocket server, NetSocket client) {
    this.server = server;
    this.client = client;
}

public Vps proxy() {
    //转发到客户端
    server.handler(buffer -> {
        System.out.println("111==" + BytesHelper.string(buffer.getBytes()));
        client.write(buffer);
    });
    //转发给终端
    client.handler(buffer -> {
        System.out.println("222==" + BytesHelper.string(buffer.getBytes()));
        server.write(buffer);
    });
    //服务关闭
    server.closeHandler(v -> client.close());
    client.closeHandler(v -> server.close());
    //服务异常
    server.exceptionHandler(e -> {
        e.printStackTrace();
        close();
    });
    client.exceptionHandler(e -> {
        e.printStackTrace();
        close();
    }); return this;
}

private void close() {
    server.close();
    client.close();
}

}
`

`

ssh -p 10022 [email protected]

Bad packet length 1231976033.
ssh_dispatch_run_fatal: Connection to 10.21.101.149 port 10022: message authentication code incorrect
`

@losyn losyn added the bug label Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant