This commit is contained in:
wujiawei 2023-03-02 22:55:19 +08:00
parent 6cb17fbd58
commit 04f0524971
27 changed files with 117 additions and 33 deletions

View File

@ -3,13 +3,13 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>netty-proxy</artifactId>
<artifactId>lazy-netty-proxy</artifactId>
<groupId>com.wu</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>netty-proxy-client</artifactId>
<artifactId>lazy-netty-proxy-client</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
@ -18,7 +18,7 @@
<dependencies>
<dependency>
<groupId>com.wu</groupId>
<artifactId>netty-proxy-common</artifactId>
<artifactId>lazy-netty-proxy-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>

View File

@ -0,0 +1,11 @@
package com.lazy.netty.proxy.client;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ClientApplication {
public static void main(String[] args) {
SpringApplication.run(ClientApplication.class, args);
}
}

View File

@ -1,4 +1,4 @@
package com.luck.client.controller;
package com.lazy.netty.proxy.client.controller;
import com.wu.framework.inner.layer.web.EasyController;
import com.wu.framework.response.Result;

View File

@ -0,0 +1,38 @@
package com.lazy.netty.proxy.client.proxy;
import com.lazy.netty.proxy.client.proxy.config.ClientProxyConfigurationProperties;
import com.lazy.netty.proxy.client.proxy.netty.Constant;
import com.lazy.netty.proxy.client.proxy.netty.ProxySocket;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
@Component
public class NettyProxyAutoConfiguration {
private final ServerProperties serverProperties;
private final ClientProxyConfigurationProperties clientProxyConfigurationProperties;
public NettyProxyAutoConfiguration(ServerProperties serverProperties, ClientProxyConfigurationProperties clientProxyConfigurationProperties) {
this.serverProperties = serverProperties;
this.clientProxyConfigurationProperties = clientProxyConfigurationProperties;
}
@Bean
public Thread xx() {
return new Thread(() -> {
Constant.serverIp = clientProxyConfigurationProperties.getServerIp();
Constant.serverPort = clientProxyConfigurationProperties.getServerPort();
Constant.realPort = serverProperties.getPort();
// 连接代理服务
try {
ProxySocket.connectProxyServer();
} catch (Exception e) {
e.printStackTrace();
}
});
}
}

View File

@ -0,0 +1,24 @@
package com.lazy.netty.proxy.client.proxy.config;
import lombok.Data;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "spring.lazy.proxy")
public class ClientProxyConfigurationProperties {
/**
* 服务端口
*/
private int serverPort = 16001;
/**
* 服务IP
*/
private String serverIp = "127.0.0.1";
}

View File

@ -1,4 +1,4 @@
package com.luck.client;
package com.lazy.netty.proxy.client.proxy.netty;
public class ClientStart {

View File

@ -1,4 +1,4 @@
package com.luck.client;
package com.lazy.netty.proxy.client.proxy.netty;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;

View File

@ -1,4 +1,4 @@
package com.luck.client;
package com.lazy.netty.proxy.client.proxy.netty;
import com.luck.msg.MyMsg;
import io.netty.buffer.ByteBuf;

View File

@ -1,8 +1,8 @@
package com.luck.client;
package com.lazy.netty.proxy.client.proxy.netty;
import com.luck.msg.MyMsg;
import com.luck.msg.MyMsgDecoder;
import com.luck.msg.MyMsgEncoder;
import com.lazy.netty.proxy.msg.MyMsgDecoder;
import com.lazy.netty.proxy.msg.MyMsgEncoder;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;

View File

@ -1,4 +1,4 @@
package com.luck.client;
package com.lazy.netty.proxy.client.proxy.netty;
import com.luck.msg.MyMsg;
import io.netty.buffer.ByteBuf;

View File

@ -1,4 +1,4 @@
package com.luck.client;
package com.lazy.netty.proxy.client.proxy.netty;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;

View File

@ -3,13 +3,13 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>netty-proxy</artifactId>
<artifactId>lazy-netty-proxy</artifactId>
<groupId>com.wu</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>netty-proxy-common</artifactId>
<artifactId>lazy-netty-proxy-common</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>

View File

@ -1,4 +1,4 @@
package com.luck.msg;
package com.lazy.netty.proxy.msg;
import java.util.Arrays;

View File

@ -1,4 +1,4 @@
package com.luck.msg;
package com.lazy.netty.proxy.msg;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;

View File

@ -1,4 +1,4 @@
package com.luck.msg;
package com.lazy.netty.proxy.msg;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;

View File

@ -3,13 +3,13 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>netty-proxy</artifactId>
<artifactId>lazy-netty-proxy</artifactId>
<groupId>com.wu</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>netty-proxy-server</artifactId>
<artifactId>lazy-netty-proxy-server</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
@ -19,7 +19,7 @@
<dependencies>
<dependency>
<groupId>com.wu</groupId>
<artifactId>netty-proxy-common</artifactId>
<artifactId>lazy-netty-proxy-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>

View File

@ -1,4 +1,4 @@
package com.luck.server;
package com.lazy.netty.proxy.server;
import com.luck.msg.MyMsg;
import io.netty.buffer.ByteBuf;

View File

@ -1,4 +1,4 @@
package com.luck.server;
package com.lazy.netty.proxy.server;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;

View File

@ -0,0 +1,11 @@
package com.lazy.netty.proxy.server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ProxyServerApplication {
public static void main(String[] args) {
SpringApplication.run(ProxyServerApplication.class,args);
}
}

View File

@ -1,7 +1,7 @@
package com.luck.server;
package com.lazy.netty.proxy.server;
import com.luck.msg.MyMsgDecoder;
import com.luck.msg.MyMsgEncoder;
import com.lazy.netty.proxy.msg.MyMsgDecoder;
import com.lazy.netty.proxy.msg.MyMsgEncoder;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;

View File

@ -1,4 +1,4 @@
package com.luck.server;
package com.lazy.netty.proxy.server;
public class ServerStart {

View File

@ -1,4 +1,4 @@
package com.luck.server;
package com.lazy.netty.proxy.server;
import com.luck.msg.MyMsg;
import io.netty.buffer.ByteBuf;

View File

@ -1,4 +1,4 @@
package com.luck.server;
package com.lazy.netty.proxy.server;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelDuplexHandler;

View File

@ -1,4 +1,4 @@
package com.luck.server.controller;
package com.lazy.netty.proxy.server.controller;
import com.wu.framework.inner.layer.web.EasyController;
import com.wu.framework.response.Result;

View File

@ -11,7 +11,7 @@
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.wu</groupId>
<artifactId>netty-proxy</artifactId>
<artifactId>lazy-netty-proxy</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>netty-proxy</name>
<description>netty-proxy</description>
@ -20,9 +20,9 @@
</properties>
<modules>
<module>netty-proxy-common</module>
<module>netty-proxy-server</module>
<module>netty-proxy-client</module>
<module>lazy-netty-proxy-common</module>
<module>lazy-netty-proxy-server</module>
<module>lazy-netty-proxy-client</module>
</modules>
<dependencies>