├── .gitignore ├── README.md ├── mitmproxy-hub.png ├── pom.xml └── src └── main ├── java ├── com │ └── deep007 │ │ └── mitmproxyjava │ │ ├── MitmHeader.java │ │ ├── MitmHeaderOrBuilder.java │ │ ├── MitmProxyHubClientServerProto.java │ │ ├── MitmRequest.java │ │ ├── MitmRequestOrBuilder.java │ │ ├── MitmResponse.java │ │ ├── MitmResponseOrBuilder.java │ │ ├── MitmproxyStartRequest.java │ │ ├── MitmproxyStartRequestOrBuilder.java │ │ ├── MitmproxyStartResponse.java │ │ ├── MitmproxyStartResponseOrBuilder.java │ │ ├── MitmproxyStopRequest.java │ │ ├── MitmproxyStopRequestOrBuilder.java │ │ ├── VoidResponse.java │ │ ├── VoidResponseOrBuilder.java │ │ ├── filter │ │ ├── Cookie.java │ │ ├── CookieCollectFilter.java │ │ └── FlowFilter.java │ │ ├── grpc │ │ ├── MitmProxyHubClientServerGrpc.java │ │ ├── MitmProxyHubServerGrpc.java │ │ └── MitmproxyFlowCallBackServer.java │ │ ├── mitmproxy │ │ └── RemoteMitmproxy.java │ │ └── modle │ │ ├── FlowHeaders.java │ │ ├── FlowRequest.java │ │ ├── FlowResponse.java │ │ └── XUtils.java └── io │ └── grpc │ └── internal │ └── MessageDeframer.java └── resources └── mitm_hub_client.proto /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | target/ 3 | .classpath 4 | .settings/ 5 | .pydevproject 6 | *__pycache__* 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # java版mitmproxy-java 2 | 3 | https://github.com/CreditTone/mitmproxy-java 4 | 5 | [mitmproxy](https://github.com/mitmproxy/mitmproxy)作为一款出色中间人攻击工具,它在渗透、爬虫、ajax-hook、抓包等场景中表现的相当稳定和出色。但由于原生项目是python的缘故,使得跨语言使用mitmproxy显的非常吃力。经常借助于中间件或单独开发http服务来于mitmproxy进行通信。为此[mitmproxy-java](https://github.com/CreditTone/mitmproxy-java)基于[mitmproxy-hub](https://github.com/CreditTone/mitmproxy-hub "mitmproxy-hub")实现了java版mitmproxy客户端。你可以像使用原生[mitmproxy](https://github.com/mitmproxy/mitmproxy)一样使用它。 6 | 7 | ### 原理介绍 8 | [mitmproxy-hub](https://github.com/CreditTone/mitmproxy-hub "mitmproxy-hub")定义了其他任何语言可以生成的proto3序列化代码,借助于grpc高效的跨进程通信。使得其他语言可以对mitmproxy内部的流量进行无死角的监控。 9 | 10 | ![mitmproxy-hub架构图](./mitmproxy-hub.png "mitmproxy-hub架构图") 11 | 12 | ### 为什么不直接使用browsermob-proxy、LittleProxy等java原生语言开发的mitm代理? 13 | browsermob-proxy/LittleProxy对于高并发场景下的表现十分不稳定,而且在大文件传输上经常有内存溢出现象。主要是因为两个项目的作者均已在3年前就已经停止更新。本人猜想也许是看到mitmproxy太过于强大,没有继续发展下去的希望。就像google headless一出来phantomjs作者就停止更新一样。而mitmproxy在开源社区一直是高活跃项目,bug等问题修复及时。借用grpc远程控制mitmproxy是一种站在巨人的肩膀上的方法。 14 | 15 | ### MitmproxyFlowCallBackServer 16 | mitmproxy通过grpc回调回来的flows是通过MitmproxyFlowCallBackServer启动的grpc server来回调的。MitmproxyFlowCallBackServer.getInstance()可获取默认实例。当然你也可以通过public MitmproxyFlowCallBackServer(int port)构造方法创建自定义端口的实例,但请注意维护好其生命周期。 17 | 18 | 19 | ### 推荐环境 20 | ``` 21 | Mitmproxy: 5.3.0 22 | Python: 3.6.8 23 | OpenSSL: OpenSSL 1.1.1h 22 Sep 2020 24 | Platform: Darwin-20.1.0-x86_64-i386-64bit 25 | ``` 26 | 27 | ### 启动mitmproxy-hub 28 | ``` 29 | git clone https://github.com/CreditTone/mitmproxy-hub.git 30 | cd mitmproxy-hub 31 | python3 server.py //server on port 60051 32 | 33 | ``` 34 | 35 | ### maven集成mitmproxy-java 36 | ```xml 37 | 38 | com.deep007 39 | mitmproxy-java 40 | 1.0.8 41 | 42 | ``` 43 | 44 | ### 启动一个remote mitmproxy 45 | 46 | > RemoteMitmproxy构造方法一共3个,源码如下 47 | 48 | ```java 49 | /** 50 | * 启动一个Remote Mitmproxy 51 | * @param mitmproxyHubAddr mitmproxy-hub服务的ip,不知道mitmproxy-hub是什么请看https://github.com/CreditTone/mitmproxy-hub 52 | * @param mitmproxyHubPort mitmproxy-hub服务的端口 53 | * @param remoteBind 在mitmproxy-hub这个机器上启动一个mitmproxy实例,告诉它需要绑定的IP。如果是本机的话绑定127.0.0.1即可,如果不是本机绑定0.0.0.0。并在使用的时候注意本机到mitmproxy-hub服务的IP关系。相信稍微有点网络知识不必我再说了吧 54 | * @param remoteBindPort 在mitmproxy-hub这个机器上启动一个mitmproxy实例,告诉它需要绑定的端口 55 | */ 56 | public RemoteMitmproxy(String mitmproxyHubAddr, int mitmproxyHubPort, String remoteBind, int remoteBindPort) { 57 | this(mitmproxyHubAddr, mitmproxyHubPort, remoteBind, remoteBindPort, null, null); 58 | } 59 | 60 | /** 61 | * 启动一个Remote Mitmproxy 62 | * @param mitmproxyHubAddr 63 | * @param mitmproxyHubPort 64 | * @param remoteBind 65 | * @param remoteBindPort 66 | * @param upstream 启动远端mitmproxy实例的同时设置一个上游的http代理 格式如:http://http-dyn.abuyun.com:9020、http://192.168.0.101:8080。类似命令:mitmdump --mode upstream:http://192.168.0.101:8080,还不了解自己去了解https://docs.mitmproxy.org/archive/v5/concepts-modes/#upstream-proxy 67 | */ 68 | public RemoteMitmproxy(String mitmproxyHubAddr, int mitmproxyHubPort, String remoteBind, int remoteBindPort, String upstream) { 69 | this(mitmproxyHubAddr, mitmproxyHubPort, remoteBind, remoteBindPort, upstream, null); 70 | } 71 | 72 | /** 73 | * 例如:RemoteMitmproxy remoteMitmproxy = new RemoteMitmproxy("127.0.0.1", 60051, "127.0.0.1", 8866, "http://http-dyn.abuyun.com:9020", "H889CWY00SVY012D:263445C168FAE095"); 74 | * 75 | * @param mitmproxyHubAddr 76 | * @param mitmproxyHubPort 77 | * @param remoteBind 78 | * @param remoteBindPort 79 | * @param upstream 启动远端mitmproxy实例的同时设置一个上游的http代理 格式如:http://http-dyn.abuyun.com:9020、http://192.168.0.101:8080 80 | * @param upstreamAuth 如果上游的http代理有验证,则设置。 格式:H889CWY00SVY012D:263445C168FAE095 81 | */ 82 | public RemoteMitmproxy(String mitmproxyHubAddr, int mitmproxyHubPort, String remoteBind, int remoteBindPort, String upstream, String upstreamAuth) { 83 | this.mitmproxyHubAddr = mitmproxyHubAddr; 84 | this.mitmproxyHubPort = mitmproxyHubPort; 85 | this.remoteBind = remoteBind; 86 | this.remoteBindPort = remoteBindPort; 87 | this.upstream = upstream; 88 | this.upstreamAuth = upstreamAuth; 89 | } 90 | ``` 91 | 92 | ### 监控网络流量 93 | ```java 94 | public static void main(String[] args) throws InterruptedException { 95 | RemoteMitmproxy remoteMitmproxy = new RemoteMitmproxy("127.0.0.1", 60051, "127.0.0.1", 8866); 96 | remoteMitmproxy.addFlowFilter(new FlowFilter() { 97 | 98 | @Override 99 | public void filterRequest(FlowRequest flowRequest) { 100 | System.out.println(flowRequest.getUrl()); 101 | } 102 | 103 | @Override 104 | public void filterResponse(FlowResponse flowResponse) { 105 | FlowRequest flowRequest = flowResponse.getRequest(); 106 | System.out.println(flowRequest.getUrl() + " response length:" +flowResponse.getContent().length); 107 | } 108 | 109 | }); 110 | remoteMitmproxy.start(); 111 | Thread.sleep(1000 * 60 * 5); 112 | remoteMitmproxy.stop(); 113 | } 114 | ``` 115 | 116 | ### 篡改网络响应 117 | ```java 118 | public static void main(String[] args) throws InterruptedException { 119 | RemoteMitmproxy remoteMitmproxy = new RemoteMitmproxy("127.0.0.1", 60051, "127.0.0.1", 8866); 120 | remoteMitmproxy.addFlowFilter(new FlowFilter() { 121 | 122 | @Override 123 | public void filterRequest(FlowRequest flowRequest) { 124 | } 125 | 126 | @Override 127 | public void filterResponse(FlowResponse flowResponse) { 128 | FlowRequest flowRequest = flowResponse.getRequest(); 129 | if (flowRequest.getUrl().startsWith("https://www.baidu.com")) { 130 | flowResponse.setContentAsString("就不让你访问百度,哈哈!"); 131 | } 132 | } 133 | 134 | }); 135 | remoteMitmproxy.start(); 136 | Thread.sleep(1000 * 60 * 5); 137 | remoteMitmproxy.stop(); 138 | } 139 | ``` 140 | 141 | 142 | ### 劫持cookie 143 | ```java 144 | public static void main(String[] args) throws InterruptedException { 145 | RemoteMitmproxy remoteMitmproxy = new RemoteMitmproxy("127.0.0.1", 60051, "127.0.0.1", 8866); 146 | CookieCollectFilter cookieCollectFilter = new CookieCollectFilter(); 147 | remoteMitmproxy.addFlowFilter(cookieCollectFilter); 148 | remoteMitmproxy.start(); 149 | Thread.sleep(1000 * 60 * 5); 150 | remoteMitmproxy.stop(); 151 | for (Cookie cookie : cookieCollectFilter.catchCookies) { 152 | System.out.println(cookie.getDomain() + ">>>"+ cookie.getName()+"="+cookie.getValue() +" path:"+cookie.getPath()); 153 | } 154 | } 155 | ``` 156 | 157 | #### 有问题请留言谢谢! 158 | 159 | -------------------------------------------------------------------------------- /mitmproxy-hub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CreditTone/mitmproxy-java/0e3367543778459e433ce3c71a53bfd4a90d15db/mitmproxy-hub.png -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | com.deep007 6 | mitmproxy-java 7 | mitmproxy-java 8 | https://github.com/CreditTone/mitmproxy-java 9 | jar 10 | 1.0.8 11 | 12 | 13 | 14 | The Apache Software License, Version 2.0 15 | http://www.apache.org/licenses/LICENSE-2.0.txt 16 | repo 17 | 18 | 19 | 20 | 21 | 22 | guozhong 23 | 1273568669@qq.com 24 | https://github.com/CreditTone/mitmproxy-java 25 | 26 | 27 | 28 | scm:git:git@github.com:CreditTone/mitmproxy-java.git 29 | 30 | scm:git:git@github.com:CreditTone/mitmproxy-java.git 31 | 32 | git@github.com:CreditTone/mitmproxy-java.git 33 | 34 | 基于mitmproxy-hub实现的java版mitmproxy 35 | 36 | 37 | UTF-8 38 | UTF-8 39 | 40 | 1.8 41 | mitmproxy-java 42 | 43 | 44 | 45 | 46 | 47 | dev 48 | 49 | dev 50 | 51 | 52 | 53 | true 54 | 55 | 56 | 57 | 58 | 59 | release 60 | 61 | release 62 | 63 | 64 | 65 | 66 | oss 67 | https://oss.sonatype.org/content/repositories/snapshots 68 | 69 | 70 | oss 71 | https://oss.sonatype.org/service/local/staging/deploy/maven2 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | org.apache.maven.plugins 80 | maven-source-plugin 81 | 2.2.1 82 | 83 | 84 | package 85 | 86 | jar-no-fork 87 | 88 | 89 | 90 | 91 | 92 | 93 | org.apache.maven.plugins 94 | maven-javadoc-plugin 95 | 2.9.1 96 | 97 | 98 | package 99 | 100 | jar 101 | 102 | 103 | 104 | 105 | 106 | org.apache.maven.plugins 107 | maven-gpg-plugin 108 | 1.5 109 | 110 | 111 | sign-artifacts 112 | verify 113 | 114 | sign 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | beta 125 | 126 | beta 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | javax.annotation 136 | javax.annotation-api 137 | 1.3.2 138 | 139 | 140 | 141 | io.grpc 142 | grpc-netty-shaded 143 | 1.34.0 144 | 145 | 146 | io.grpc 147 | grpc-protobuf 148 | 1.34.0 149 | 150 | 151 | io.grpc 152 | grpc-stub 153 | 1.34.0 154 | 155 | 156 | 157 | ${project.name} 158 | 159 | 160 | 161 | kr.motd.maven 162 | os-maven-plugin 163 | 1.6.2 164 | 165 | 166 | 167 | 168 | org.apache.maven.plugins 169 | maven-compiler-plugin 170 | 3.0 171 | 172 | 1.8 173 | 1.8 174 | UTF-8 175 | 176 | 177 | 178 | org.apache.maven.plugins 179 | maven-javadoc-plugin 180 | 2.9.1 181 | 182 | 183 | attach-javadocs 184 | 185 | jar 186 | 187 | 188 | 189 | 190 | 191 | org.apache.maven.plugins 192 | maven-source-plugin 193 | 2.2.1 194 | 195 | 196 | attach-sources 197 | verify 198 | 199 | jar-no-fork 200 | 201 | 202 | 203 | 204 | 205 | org.apache.maven.plugins 206 | maven-resources-plugin 207 | 2.6 208 | 209 | UTF-8 210 | 211 | 212 | 213 | 234 | 235 | 236 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/MitmHeader.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | /** 7 | * Protobuf type {@code mitm.MitmHeader} 8 | */ 9 | public final class MitmHeader extends 10 | com.google.protobuf.GeneratedMessageV3 implements 11 | // @@protoc_insertion_point(message_implements:mitm.MitmHeader) 12 | MitmHeaderOrBuilder { 13 | private static final long serialVersionUID = 0L; 14 | // Use MitmHeader.newBuilder() to construct. 15 | private MitmHeader(com.google.protobuf.GeneratedMessageV3.Builder builder) { 16 | super(builder); 17 | } 18 | private MitmHeader() { 19 | name_ = ""; 20 | value_ = ""; 21 | } 22 | 23 | @java.lang.Override 24 | public final com.google.protobuf.UnknownFieldSet 25 | getUnknownFields() { 26 | return this.unknownFields; 27 | } 28 | private MitmHeader( 29 | com.google.protobuf.CodedInputStream input, 30 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 31 | throws com.google.protobuf.InvalidProtocolBufferException { 32 | this(); 33 | if (extensionRegistry == null) { 34 | throw new java.lang.NullPointerException(); 35 | } 36 | int mutable_bitField0_ = 0; 37 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 38 | com.google.protobuf.UnknownFieldSet.newBuilder(); 39 | try { 40 | boolean done = false; 41 | while (!done) { 42 | int tag = input.readTag(); 43 | switch (tag) { 44 | case 0: 45 | done = true; 46 | break; 47 | default: { 48 | if (!parseUnknownFieldProto3( 49 | input, unknownFields, extensionRegistry, tag)) { 50 | done = true; 51 | } 52 | break; 53 | } 54 | case 10: { 55 | java.lang.String s = input.readStringRequireUtf8(); 56 | 57 | name_ = s; 58 | break; 59 | } 60 | case 18: { 61 | java.lang.String s = input.readStringRequireUtf8(); 62 | 63 | value_ = s; 64 | break; 65 | } 66 | } 67 | } 68 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 69 | throw e.setUnfinishedMessage(this); 70 | } catch (java.io.IOException e) { 71 | throw new com.google.protobuf.InvalidProtocolBufferException( 72 | e).setUnfinishedMessage(this); 73 | } finally { 74 | this.unknownFields = unknownFields.build(); 75 | makeExtensionsImmutable(); 76 | } 77 | } 78 | public static final com.google.protobuf.Descriptors.Descriptor 79 | getDescriptor() { 80 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmHeader_descriptor; 81 | } 82 | 83 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 84 | internalGetFieldAccessorTable() { 85 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmHeader_fieldAccessorTable 86 | .ensureFieldAccessorsInitialized( 87 | com.deep007.mitmproxyjava.MitmHeader.class, com.deep007.mitmproxyjava.MitmHeader.Builder.class); 88 | } 89 | 90 | public static final int NAME_FIELD_NUMBER = 1; 91 | private volatile java.lang.Object name_; 92 | /** 93 | * string name = 1; 94 | */ 95 | public java.lang.String getName() { 96 | java.lang.Object ref = name_; 97 | if (ref instanceof java.lang.String) { 98 | return (java.lang.String) ref; 99 | } else { 100 | com.google.protobuf.ByteString bs = 101 | (com.google.protobuf.ByteString) ref; 102 | java.lang.String s = bs.toStringUtf8(); 103 | name_ = s; 104 | return s; 105 | } 106 | } 107 | /** 108 | * string name = 1; 109 | */ 110 | public com.google.protobuf.ByteString 111 | getNameBytes() { 112 | java.lang.Object ref = name_; 113 | if (ref instanceof java.lang.String) { 114 | com.google.protobuf.ByteString b = 115 | com.google.protobuf.ByteString.copyFromUtf8( 116 | (java.lang.String) ref); 117 | name_ = b; 118 | return b; 119 | } else { 120 | return (com.google.protobuf.ByteString) ref; 121 | } 122 | } 123 | 124 | public static final int VALUE_FIELD_NUMBER = 2; 125 | private volatile java.lang.Object value_; 126 | /** 127 | * string value = 2; 128 | */ 129 | public java.lang.String getValue() { 130 | java.lang.Object ref = value_; 131 | if (ref instanceof java.lang.String) { 132 | return (java.lang.String) ref; 133 | } else { 134 | com.google.protobuf.ByteString bs = 135 | (com.google.protobuf.ByteString) ref; 136 | java.lang.String s = bs.toStringUtf8(); 137 | value_ = s; 138 | return s; 139 | } 140 | } 141 | /** 142 | * string value = 2; 143 | */ 144 | public com.google.protobuf.ByteString 145 | getValueBytes() { 146 | java.lang.Object ref = value_; 147 | if (ref instanceof java.lang.String) { 148 | com.google.protobuf.ByteString b = 149 | com.google.protobuf.ByteString.copyFromUtf8( 150 | (java.lang.String) ref); 151 | value_ = b; 152 | return b; 153 | } else { 154 | return (com.google.protobuf.ByteString) ref; 155 | } 156 | } 157 | 158 | private byte memoizedIsInitialized = -1; 159 | public final boolean isInitialized() { 160 | byte isInitialized = memoizedIsInitialized; 161 | if (isInitialized == 1) return true; 162 | if (isInitialized == 0) return false; 163 | 164 | memoizedIsInitialized = 1; 165 | return true; 166 | } 167 | 168 | public void writeTo(com.google.protobuf.CodedOutputStream output) 169 | throws java.io.IOException { 170 | if (!getNameBytes().isEmpty()) { 171 | com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); 172 | } 173 | if (!getValueBytes().isEmpty()) { 174 | com.google.protobuf.GeneratedMessageV3.writeString(output, 2, value_); 175 | } 176 | unknownFields.writeTo(output); 177 | } 178 | 179 | public int getSerializedSize() { 180 | int size = memoizedSize; 181 | if (size != -1) return size; 182 | 183 | size = 0; 184 | if (!getNameBytes().isEmpty()) { 185 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); 186 | } 187 | if (!getValueBytes().isEmpty()) { 188 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, value_); 189 | } 190 | size += unknownFields.getSerializedSize(); 191 | memoizedSize = size; 192 | return size; 193 | } 194 | 195 | @java.lang.Override 196 | public boolean equals(final java.lang.Object obj) { 197 | if (obj == this) { 198 | return true; 199 | } 200 | if (!(obj instanceof com.deep007.mitmproxyjava.MitmHeader)) { 201 | return super.equals(obj); 202 | } 203 | com.deep007.mitmproxyjava.MitmHeader other = (com.deep007.mitmproxyjava.MitmHeader) obj; 204 | 205 | boolean result = true; 206 | result = result && getName() 207 | .equals(other.getName()); 208 | result = result && getValue() 209 | .equals(other.getValue()); 210 | result = result && unknownFields.equals(other.unknownFields); 211 | return result; 212 | } 213 | 214 | @java.lang.Override 215 | public int hashCode() { 216 | if (memoizedHashCode != 0) { 217 | return memoizedHashCode; 218 | } 219 | int hash = 41; 220 | hash = (19 * hash) + getDescriptor().hashCode(); 221 | hash = (37 * hash) + NAME_FIELD_NUMBER; 222 | hash = (53 * hash) + getName().hashCode(); 223 | hash = (37 * hash) + VALUE_FIELD_NUMBER; 224 | hash = (53 * hash) + getValue().hashCode(); 225 | hash = (29 * hash) + unknownFields.hashCode(); 226 | memoizedHashCode = hash; 227 | return hash; 228 | } 229 | 230 | public static com.deep007.mitmproxyjava.MitmHeader parseFrom( 231 | java.nio.ByteBuffer data) 232 | throws com.google.protobuf.InvalidProtocolBufferException { 233 | return PARSER.parseFrom(data); 234 | } 235 | public static com.deep007.mitmproxyjava.MitmHeader parseFrom( 236 | java.nio.ByteBuffer data, 237 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 238 | throws com.google.protobuf.InvalidProtocolBufferException { 239 | return PARSER.parseFrom(data, extensionRegistry); 240 | } 241 | public static com.deep007.mitmproxyjava.MitmHeader parseFrom( 242 | com.google.protobuf.ByteString data) 243 | throws com.google.protobuf.InvalidProtocolBufferException { 244 | return PARSER.parseFrom(data); 245 | } 246 | public static com.deep007.mitmproxyjava.MitmHeader parseFrom( 247 | com.google.protobuf.ByteString data, 248 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 249 | throws com.google.protobuf.InvalidProtocolBufferException { 250 | return PARSER.parseFrom(data, extensionRegistry); 251 | } 252 | public static com.deep007.mitmproxyjava.MitmHeader parseFrom(byte[] data) 253 | throws com.google.protobuf.InvalidProtocolBufferException { 254 | return PARSER.parseFrom(data); 255 | } 256 | public static com.deep007.mitmproxyjava.MitmHeader parseFrom( 257 | byte[] data, 258 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 259 | throws com.google.protobuf.InvalidProtocolBufferException { 260 | return PARSER.parseFrom(data, extensionRegistry); 261 | } 262 | public static com.deep007.mitmproxyjava.MitmHeader parseFrom(java.io.InputStream input) 263 | throws java.io.IOException { 264 | return com.google.protobuf.GeneratedMessageV3 265 | .parseWithIOException(PARSER, input); 266 | } 267 | public static com.deep007.mitmproxyjava.MitmHeader parseFrom( 268 | java.io.InputStream input, 269 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 270 | throws java.io.IOException { 271 | return com.google.protobuf.GeneratedMessageV3 272 | .parseWithIOException(PARSER, input, extensionRegistry); 273 | } 274 | public static com.deep007.mitmproxyjava.MitmHeader parseDelimitedFrom(java.io.InputStream input) 275 | throws java.io.IOException { 276 | return com.google.protobuf.GeneratedMessageV3 277 | .parseDelimitedWithIOException(PARSER, input); 278 | } 279 | public static com.deep007.mitmproxyjava.MitmHeader parseDelimitedFrom( 280 | java.io.InputStream input, 281 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 282 | throws java.io.IOException { 283 | return com.google.protobuf.GeneratedMessageV3 284 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 285 | } 286 | public static com.deep007.mitmproxyjava.MitmHeader parseFrom( 287 | com.google.protobuf.CodedInputStream input) 288 | throws java.io.IOException { 289 | return com.google.protobuf.GeneratedMessageV3 290 | .parseWithIOException(PARSER, input); 291 | } 292 | public static com.deep007.mitmproxyjava.MitmHeader parseFrom( 293 | com.google.protobuf.CodedInputStream input, 294 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 295 | throws java.io.IOException { 296 | return com.google.protobuf.GeneratedMessageV3 297 | .parseWithIOException(PARSER, input, extensionRegistry); 298 | } 299 | 300 | public Builder newBuilderForType() { return newBuilder(); } 301 | public static Builder newBuilder() { 302 | return DEFAULT_INSTANCE.toBuilder(); 303 | } 304 | public static Builder newBuilder(com.deep007.mitmproxyjava.MitmHeader prototype) { 305 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 306 | } 307 | public Builder toBuilder() { 308 | return this == DEFAULT_INSTANCE 309 | ? new Builder() : new Builder().mergeFrom(this); 310 | } 311 | 312 | @java.lang.Override 313 | protected Builder newBuilderForType( 314 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 315 | Builder builder = new Builder(parent); 316 | return builder; 317 | } 318 | /** 319 | * Protobuf type {@code mitm.MitmHeader} 320 | */ 321 | public static final class Builder extends 322 | com.google.protobuf.GeneratedMessageV3.Builder implements 323 | // @@protoc_insertion_point(builder_implements:mitm.MitmHeader) 324 | com.deep007.mitmproxyjava.MitmHeaderOrBuilder { 325 | public static final com.google.protobuf.Descriptors.Descriptor 326 | getDescriptor() { 327 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmHeader_descriptor; 328 | } 329 | 330 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 331 | internalGetFieldAccessorTable() { 332 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmHeader_fieldAccessorTable 333 | .ensureFieldAccessorsInitialized( 334 | com.deep007.mitmproxyjava.MitmHeader.class, com.deep007.mitmproxyjava.MitmHeader.Builder.class); 335 | } 336 | 337 | // Construct using com.deep007.mitmproxyjava.MitmHeader.newBuilder() 338 | private Builder() { 339 | maybeForceBuilderInitialization(); 340 | } 341 | 342 | private Builder( 343 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 344 | super(parent); 345 | maybeForceBuilderInitialization(); 346 | } 347 | private void maybeForceBuilderInitialization() { 348 | if (com.google.protobuf.GeneratedMessageV3 349 | .alwaysUseFieldBuilders) { 350 | } 351 | } 352 | public Builder clear() { 353 | super.clear(); 354 | name_ = ""; 355 | 356 | value_ = ""; 357 | 358 | return this; 359 | } 360 | 361 | public com.google.protobuf.Descriptors.Descriptor 362 | getDescriptorForType() { 363 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmHeader_descriptor; 364 | } 365 | 366 | public com.deep007.mitmproxyjava.MitmHeader getDefaultInstanceForType() { 367 | return com.deep007.mitmproxyjava.MitmHeader.getDefaultInstance(); 368 | } 369 | 370 | public com.deep007.mitmproxyjava.MitmHeader build() { 371 | com.deep007.mitmproxyjava.MitmHeader result = buildPartial(); 372 | if (!result.isInitialized()) { 373 | throw newUninitializedMessageException(result); 374 | } 375 | return result; 376 | } 377 | 378 | public com.deep007.mitmproxyjava.MitmHeader buildPartial() { 379 | com.deep007.mitmproxyjava.MitmHeader result = new com.deep007.mitmproxyjava.MitmHeader(this); 380 | result.name_ = name_; 381 | result.value_ = value_; 382 | onBuilt(); 383 | return result; 384 | } 385 | 386 | public Builder clone() { 387 | return (Builder) super.clone(); 388 | } 389 | public Builder setField( 390 | com.google.protobuf.Descriptors.FieldDescriptor field, 391 | java.lang.Object value) { 392 | return (Builder) super.setField(field, value); 393 | } 394 | public Builder clearField( 395 | com.google.protobuf.Descriptors.FieldDescriptor field) { 396 | return (Builder) super.clearField(field); 397 | } 398 | public Builder clearOneof( 399 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 400 | return (Builder) super.clearOneof(oneof); 401 | } 402 | public Builder setRepeatedField( 403 | com.google.protobuf.Descriptors.FieldDescriptor field, 404 | int index, java.lang.Object value) { 405 | return (Builder) super.setRepeatedField(field, index, value); 406 | } 407 | public Builder addRepeatedField( 408 | com.google.protobuf.Descriptors.FieldDescriptor field, 409 | java.lang.Object value) { 410 | return (Builder) super.addRepeatedField(field, value); 411 | } 412 | public Builder mergeFrom(com.google.protobuf.Message other) { 413 | if (other instanceof com.deep007.mitmproxyjava.MitmHeader) { 414 | return mergeFrom((com.deep007.mitmproxyjava.MitmHeader)other); 415 | } else { 416 | super.mergeFrom(other); 417 | return this; 418 | } 419 | } 420 | 421 | public Builder mergeFrom(com.deep007.mitmproxyjava.MitmHeader other) { 422 | if (other == com.deep007.mitmproxyjava.MitmHeader.getDefaultInstance()) return this; 423 | if (!other.getName().isEmpty()) { 424 | name_ = other.name_; 425 | onChanged(); 426 | } 427 | if (!other.getValue().isEmpty()) { 428 | value_ = other.value_; 429 | onChanged(); 430 | } 431 | this.mergeUnknownFields(other.unknownFields); 432 | onChanged(); 433 | return this; 434 | } 435 | 436 | public final boolean isInitialized() { 437 | return true; 438 | } 439 | 440 | public Builder mergeFrom( 441 | com.google.protobuf.CodedInputStream input, 442 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 443 | throws java.io.IOException { 444 | com.deep007.mitmproxyjava.MitmHeader parsedMessage = null; 445 | try { 446 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 447 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 448 | parsedMessage = (com.deep007.mitmproxyjava.MitmHeader) e.getUnfinishedMessage(); 449 | throw e.unwrapIOException(); 450 | } finally { 451 | if (parsedMessage != null) { 452 | mergeFrom(parsedMessage); 453 | } 454 | } 455 | return this; 456 | } 457 | 458 | private java.lang.Object name_ = ""; 459 | /** 460 | * string name = 1; 461 | */ 462 | public java.lang.String getName() { 463 | java.lang.Object ref = name_; 464 | if (!(ref instanceof java.lang.String)) { 465 | com.google.protobuf.ByteString bs = 466 | (com.google.protobuf.ByteString) ref; 467 | java.lang.String s = bs.toStringUtf8(); 468 | name_ = s; 469 | return s; 470 | } else { 471 | return (java.lang.String) ref; 472 | } 473 | } 474 | /** 475 | * string name = 1; 476 | */ 477 | public com.google.protobuf.ByteString 478 | getNameBytes() { 479 | java.lang.Object ref = name_; 480 | if (ref instanceof String) { 481 | com.google.protobuf.ByteString b = 482 | com.google.protobuf.ByteString.copyFromUtf8( 483 | (java.lang.String) ref); 484 | name_ = b; 485 | return b; 486 | } else { 487 | return (com.google.protobuf.ByteString) ref; 488 | } 489 | } 490 | /** 491 | * string name = 1; 492 | */ 493 | public Builder setName( 494 | java.lang.String value) { 495 | if (value == null) { 496 | throw new NullPointerException(); 497 | } 498 | 499 | name_ = value; 500 | onChanged(); 501 | return this; 502 | } 503 | /** 504 | * string name = 1; 505 | */ 506 | public Builder clearName() { 507 | 508 | name_ = getDefaultInstance().getName(); 509 | onChanged(); 510 | return this; 511 | } 512 | /** 513 | * string name = 1; 514 | */ 515 | public Builder setNameBytes( 516 | com.google.protobuf.ByteString value) { 517 | if (value == null) { 518 | throw new NullPointerException(); 519 | } 520 | checkByteStringIsUtf8(value); 521 | 522 | name_ = value; 523 | onChanged(); 524 | return this; 525 | } 526 | 527 | private java.lang.Object value_ = ""; 528 | /** 529 | * string value = 2; 530 | */ 531 | public java.lang.String getValue() { 532 | java.lang.Object ref = value_; 533 | if (!(ref instanceof java.lang.String)) { 534 | com.google.protobuf.ByteString bs = 535 | (com.google.protobuf.ByteString) ref; 536 | java.lang.String s = bs.toStringUtf8(); 537 | value_ = s; 538 | return s; 539 | } else { 540 | return (java.lang.String) ref; 541 | } 542 | } 543 | /** 544 | * string value = 2; 545 | */ 546 | public com.google.protobuf.ByteString 547 | getValueBytes() { 548 | java.lang.Object ref = value_; 549 | if (ref instanceof String) { 550 | com.google.protobuf.ByteString b = 551 | com.google.protobuf.ByteString.copyFromUtf8( 552 | (java.lang.String) ref); 553 | value_ = b; 554 | return b; 555 | } else { 556 | return (com.google.protobuf.ByteString) ref; 557 | } 558 | } 559 | /** 560 | * string value = 2; 561 | */ 562 | public Builder setValue( 563 | java.lang.String value) { 564 | if (value == null) { 565 | throw new NullPointerException(); 566 | } 567 | 568 | value_ = value; 569 | onChanged(); 570 | return this; 571 | } 572 | /** 573 | * string value = 2; 574 | */ 575 | public Builder clearValue() { 576 | 577 | value_ = getDefaultInstance().getValue(); 578 | onChanged(); 579 | return this; 580 | } 581 | /** 582 | * string value = 2; 583 | */ 584 | public Builder setValueBytes( 585 | com.google.protobuf.ByteString value) { 586 | if (value == null) { 587 | throw new NullPointerException(); 588 | } 589 | checkByteStringIsUtf8(value); 590 | 591 | value_ = value; 592 | onChanged(); 593 | return this; 594 | } 595 | public final Builder setUnknownFields( 596 | final com.google.protobuf.UnknownFieldSet unknownFields) { 597 | return super.setUnknownFieldsProto3(unknownFields); 598 | } 599 | 600 | public final Builder mergeUnknownFields( 601 | final com.google.protobuf.UnknownFieldSet unknownFields) { 602 | return super.mergeUnknownFields(unknownFields); 603 | } 604 | 605 | 606 | // @@protoc_insertion_point(builder_scope:mitm.MitmHeader) 607 | } 608 | 609 | // @@protoc_insertion_point(class_scope:mitm.MitmHeader) 610 | private static final com.deep007.mitmproxyjava.MitmHeader DEFAULT_INSTANCE; 611 | static { 612 | DEFAULT_INSTANCE = new com.deep007.mitmproxyjava.MitmHeader(); 613 | } 614 | 615 | public static com.deep007.mitmproxyjava.MitmHeader getDefaultInstance() { 616 | return DEFAULT_INSTANCE; 617 | } 618 | 619 | private static final com.google.protobuf.Parser 620 | PARSER = new com.google.protobuf.AbstractParser() { 621 | public MitmHeader parsePartialFrom( 622 | com.google.protobuf.CodedInputStream input, 623 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 624 | throws com.google.protobuf.InvalidProtocolBufferException { 625 | return new MitmHeader(input, extensionRegistry); 626 | } 627 | }; 628 | 629 | public static com.google.protobuf.Parser parser() { 630 | return PARSER; 631 | } 632 | 633 | @java.lang.Override 634 | public com.google.protobuf.Parser getParserForType() { 635 | return PARSER; 636 | } 637 | 638 | public com.deep007.mitmproxyjava.MitmHeader getDefaultInstanceForType() { 639 | return DEFAULT_INSTANCE; 640 | } 641 | 642 | } 643 | 644 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/MitmHeaderOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | public interface MitmHeaderOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:mitm.MitmHeader) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * string name = 1; 12 | */ 13 | java.lang.String getName(); 14 | /** 15 | * string name = 1; 16 | */ 17 | com.google.protobuf.ByteString 18 | getNameBytes(); 19 | 20 | /** 21 | * string value = 2; 22 | */ 23 | java.lang.String getValue(); 24 | /** 25 | * string value = 2; 26 | */ 27 | com.google.protobuf.ByteString 28 | getValueBytes(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/MitmProxyHubClientServerProto.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | public final class MitmProxyHubClientServerProto { 7 | private MitmProxyHubClientServerProto() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | static final com.google.protobuf.Descriptors.Descriptor 18 | internal_static_mitm_VoidResponse_descriptor; 19 | static final 20 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 21 | internal_static_mitm_VoidResponse_fieldAccessorTable; 22 | static final com.google.protobuf.Descriptors.Descriptor 23 | internal_static_mitm_MitmproxyStartRequest_descriptor; 24 | static final 25 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 26 | internal_static_mitm_MitmproxyStartRequest_fieldAccessorTable; 27 | static final com.google.protobuf.Descriptors.Descriptor 28 | internal_static_mitm_MitmproxyStartResponse_descriptor; 29 | static final 30 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 31 | internal_static_mitm_MitmproxyStartResponse_fieldAccessorTable; 32 | static final com.google.protobuf.Descriptors.Descriptor 33 | internal_static_mitm_MitmproxyStopRequest_descriptor; 34 | static final 35 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 36 | internal_static_mitm_MitmproxyStopRequest_fieldAccessorTable; 37 | static final com.google.protobuf.Descriptors.Descriptor 38 | internal_static_mitm_MitmHeader_descriptor; 39 | static final 40 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 41 | internal_static_mitm_MitmHeader_fieldAccessorTable; 42 | static final com.google.protobuf.Descriptors.Descriptor 43 | internal_static_mitm_MitmRequest_descriptor; 44 | static final 45 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 46 | internal_static_mitm_MitmRequest_fieldAccessorTable; 47 | static final com.google.protobuf.Descriptors.Descriptor 48 | internal_static_mitm_MitmResponse_descriptor; 49 | static final 50 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 51 | internal_static_mitm_MitmResponse_fieldAccessorTable; 52 | 53 | public static com.google.protobuf.Descriptors.FileDescriptor 54 | getDescriptor() { 55 | return descriptor; 56 | } 57 | private static com.google.protobuf.Descriptors.FileDescriptor 58 | descriptor; 59 | static { 60 | java.lang.String[] descriptorData = { 61 | "\n\025mitm_hub_client.proto\022\004mitm\"\016\n\014VoidRes" + 62 | "ponse\"\223\001\n\025MitmproxyStartRequest\022\014\n\004bind\030" + 63 | "\001 \001(\t\022\014\n\004port\030\002 \001(\005\022\032\n\022callbackServerAdd" + 64 | "r\030\003 \001(\t\022\032\n\022callbackServerPort\030\004 \001(\005\022\020\n\010u" + 65 | "pstream\030\005 \001(\t\022\024\n\014upstreamAuth\030\006 \001(\t\"-\n\026M" + 66 | "itmproxyStartResponse\022\023\n\013mitmproxyId\030\001 \001" + 67 | "(\t\"+\n\024MitmproxyStopRequest\022\023\n\013mitmproxyI" + 68 | "d\030\001 \001(\t\")\n\nMitmHeader\022\014\n\004name\030\001 \001(\t\022\r\n\005v" + 69 | "alue\030\002 \001(\t\"s\n\013MitmRequest\022\013\n\003url\030\001 \001(\t\022\016" + 70 | "\n\006method\030\002 \001(\t\022!\n\007headers\030\003 \003(\0132\020.mitm.M" + 71 | "itmHeader\022\017\n\007content\030\004 \001(\014\022\023\n\013mitmproxyI" + 72 | "d\030\005 \001(\t\"\217\001\n\014MitmResponse\022\"\n\007request\030\001 \001(" + 73 | "\0132\021.mitm.MitmRequest\022!\n\007headers\030\002 \003(\0132\020." + 74 | "mitm.MitmHeader\022\017\n\007content\030\003 \001(\014\022\022\n\nstat" + 75 | "usCode\030\004 \001(\005\022\023\n\013mitmproxyId\030\005 \001(\t2\224\001\n\022Mi" + 76 | "tmProxyHubServer\022D\n\005start\022\033.mitm.Mitmpro" + 77 | "xyStartRequest\032\034.mitm.MitmproxyStartResp" + 78 | "onse\"\000\0228\n\004stop\022\032.mitm.MitmproxyStopReque" + 79 | "st\032\022.mitm.VoidResponse\"\0002\217\001\n\030MitmProxyHu" + 80 | "bClientServer\0227\n\ronMitmRequest\022\021.mitm.Mi" + 81 | "tmRequest\032\021.mitm.MitmRequest\"\000\022:\n\016onMitm" + 82 | "Response\022\022.mitm.MitmResponse\032\022.mitm.Mitm" + 83 | "Response\"\000B<\n\031com.deep007.mitmproxyjavaB" + 84 | "\035MitmProxyHubClientServerProtoP\001b\006proto3" 85 | }; 86 | com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = 87 | new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { 88 | public com.google.protobuf.ExtensionRegistry assignDescriptors( 89 | com.google.protobuf.Descriptors.FileDescriptor root) { 90 | descriptor = root; 91 | return null; 92 | } 93 | }; 94 | com.google.protobuf.Descriptors.FileDescriptor 95 | .internalBuildGeneratedFileFrom(descriptorData, 96 | new com.google.protobuf.Descriptors.FileDescriptor[] { 97 | }, assigner); 98 | internal_static_mitm_VoidResponse_descriptor = 99 | getDescriptor().getMessageTypes().get(0); 100 | internal_static_mitm_VoidResponse_fieldAccessorTable = new 101 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 102 | internal_static_mitm_VoidResponse_descriptor, 103 | new java.lang.String[] { }); 104 | internal_static_mitm_MitmproxyStartRequest_descriptor = 105 | getDescriptor().getMessageTypes().get(1); 106 | internal_static_mitm_MitmproxyStartRequest_fieldAccessorTable = new 107 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 108 | internal_static_mitm_MitmproxyStartRequest_descriptor, 109 | new java.lang.String[] { "Bind", "Port", "CallbackServerAddr", "CallbackServerPort", "Upstream", "UpstreamAuth", }); 110 | internal_static_mitm_MitmproxyStartResponse_descriptor = 111 | getDescriptor().getMessageTypes().get(2); 112 | internal_static_mitm_MitmproxyStartResponse_fieldAccessorTable = new 113 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 114 | internal_static_mitm_MitmproxyStartResponse_descriptor, 115 | new java.lang.String[] { "MitmproxyId", }); 116 | internal_static_mitm_MitmproxyStopRequest_descriptor = 117 | getDescriptor().getMessageTypes().get(3); 118 | internal_static_mitm_MitmproxyStopRequest_fieldAccessorTable = new 119 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 120 | internal_static_mitm_MitmproxyStopRequest_descriptor, 121 | new java.lang.String[] { "MitmproxyId", }); 122 | internal_static_mitm_MitmHeader_descriptor = 123 | getDescriptor().getMessageTypes().get(4); 124 | internal_static_mitm_MitmHeader_fieldAccessorTable = new 125 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 126 | internal_static_mitm_MitmHeader_descriptor, 127 | new java.lang.String[] { "Name", "Value", }); 128 | internal_static_mitm_MitmRequest_descriptor = 129 | getDescriptor().getMessageTypes().get(5); 130 | internal_static_mitm_MitmRequest_fieldAccessorTable = new 131 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 132 | internal_static_mitm_MitmRequest_descriptor, 133 | new java.lang.String[] { "Url", "Method", "Headers", "Content", "MitmproxyId", }); 134 | internal_static_mitm_MitmResponse_descriptor = 135 | getDescriptor().getMessageTypes().get(6); 136 | internal_static_mitm_MitmResponse_fieldAccessorTable = new 137 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 138 | internal_static_mitm_MitmResponse_descriptor, 139 | new java.lang.String[] { "Request", "Headers", "Content", "StatusCode", "MitmproxyId", }); 140 | } 141 | 142 | // @@protoc_insertion_point(outer_class_scope) 143 | } 144 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/MitmRequestOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | public interface MitmRequestOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:mitm.MitmRequest) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * string url = 1; 12 | */ 13 | java.lang.String getUrl(); 14 | /** 15 | * string url = 1; 16 | */ 17 | com.google.protobuf.ByteString 18 | getUrlBytes(); 19 | 20 | /** 21 | * string method = 2; 22 | */ 23 | java.lang.String getMethod(); 24 | /** 25 | * string method = 2; 26 | */ 27 | com.google.protobuf.ByteString 28 | getMethodBytes(); 29 | 30 | /** 31 | * repeated .mitm.MitmHeader headers = 3; 32 | */ 33 | java.util.List 34 | getHeadersList(); 35 | /** 36 | * repeated .mitm.MitmHeader headers = 3; 37 | */ 38 | com.deep007.mitmproxyjava.MitmHeader getHeaders(int index); 39 | /** 40 | * repeated .mitm.MitmHeader headers = 3; 41 | */ 42 | int getHeadersCount(); 43 | /** 44 | * repeated .mitm.MitmHeader headers = 3; 45 | */ 46 | java.util.List 47 | getHeadersOrBuilderList(); 48 | /** 49 | * repeated .mitm.MitmHeader headers = 3; 50 | */ 51 | com.deep007.mitmproxyjava.MitmHeaderOrBuilder getHeadersOrBuilder( 52 | int index); 53 | 54 | /** 55 | * bytes content = 4; 56 | */ 57 | com.google.protobuf.ByteString getContent(); 58 | 59 | /** 60 | * string mitmproxyId = 5; 61 | */ 62 | java.lang.String getMitmproxyId(); 63 | /** 64 | * string mitmproxyId = 5; 65 | */ 66 | com.google.protobuf.ByteString 67 | getMitmproxyIdBytes(); 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/MitmResponseOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | public interface MitmResponseOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:mitm.MitmResponse) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * .mitm.MitmRequest request = 1; 12 | */ 13 | boolean hasRequest(); 14 | /** 15 | * .mitm.MitmRequest request = 1; 16 | */ 17 | com.deep007.mitmproxyjava.MitmRequest getRequest(); 18 | /** 19 | * .mitm.MitmRequest request = 1; 20 | */ 21 | com.deep007.mitmproxyjava.MitmRequestOrBuilder getRequestOrBuilder(); 22 | 23 | /** 24 | * repeated .mitm.MitmHeader headers = 2; 25 | */ 26 | java.util.List 27 | getHeadersList(); 28 | /** 29 | * repeated .mitm.MitmHeader headers = 2; 30 | */ 31 | com.deep007.mitmproxyjava.MitmHeader getHeaders(int index); 32 | /** 33 | * repeated .mitm.MitmHeader headers = 2; 34 | */ 35 | int getHeadersCount(); 36 | /** 37 | * repeated .mitm.MitmHeader headers = 2; 38 | */ 39 | java.util.List 40 | getHeadersOrBuilderList(); 41 | /** 42 | * repeated .mitm.MitmHeader headers = 2; 43 | */ 44 | com.deep007.mitmproxyjava.MitmHeaderOrBuilder getHeadersOrBuilder( 45 | int index); 46 | 47 | /** 48 | * bytes content = 3; 49 | */ 50 | com.google.protobuf.ByteString getContent(); 51 | 52 | /** 53 | * int32 statusCode = 4; 54 | */ 55 | int getStatusCode(); 56 | 57 | /** 58 | * string mitmproxyId = 5; 59 | */ 60 | java.lang.String getMitmproxyId(); 61 | /** 62 | * string mitmproxyId = 5; 63 | */ 64 | com.google.protobuf.ByteString 65 | getMitmproxyIdBytes(); 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/MitmproxyStartRequest.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | /** 7 | * Protobuf type {@code mitm.MitmproxyStartRequest} 8 | */ 9 | public final class MitmproxyStartRequest extends 10 | com.google.protobuf.GeneratedMessageV3 implements 11 | // @@protoc_insertion_point(message_implements:mitm.MitmproxyStartRequest) 12 | MitmproxyStartRequestOrBuilder { 13 | private static final long serialVersionUID = 0L; 14 | // Use MitmproxyStartRequest.newBuilder() to construct. 15 | private MitmproxyStartRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { 16 | super(builder); 17 | } 18 | private MitmproxyStartRequest() { 19 | bind_ = ""; 20 | port_ = 0; 21 | callbackServerAddr_ = ""; 22 | callbackServerPort_ = 0; 23 | upstream_ = ""; 24 | upstreamAuth_ = ""; 25 | } 26 | 27 | @java.lang.Override 28 | public final com.google.protobuf.UnknownFieldSet 29 | getUnknownFields() { 30 | return this.unknownFields; 31 | } 32 | private MitmproxyStartRequest( 33 | com.google.protobuf.CodedInputStream input, 34 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 35 | throws com.google.protobuf.InvalidProtocolBufferException { 36 | this(); 37 | if (extensionRegistry == null) { 38 | throw new java.lang.NullPointerException(); 39 | } 40 | int mutable_bitField0_ = 0; 41 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 42 | com.google.protobuf.UnknownFieldSet.newBuilder(); 43 | try { 44 | boolean done = false; 45 | while (!done) { 46 | int tag = input.readTag(); 47 | switch (tag) { 48 | case 0: 49 | done = true; 50 | break; 51 | default: { 52 | if (!parseUnknownFieldProto3( 53 | input, unknownFields, extensionRegistry, tag)) { 54 | done = true; 55 | } 56 | break; 57 | } 58 | case 10: { 59 | java.lang.String s = input.readStringRequireUtf8(); 60 | 61 | bind_ = s; 62 | break; 63 | } 64 | case 16: { 65 | 66 | port_ = input.readInt32(); 67 | break; 68 | } 69 | case 26: { 70 | java.lang.String s = input.readStringRequireUtf8(); 71 | 72 | callbackServerAddr_ = s; 73 | break; 74 | } 75 | case 32: { 76 | 77 | callbackServerPort_ = input.readInt32(); 78 | break; 79 | } 80 | case 42: { 81 | java.lang.String s = input.readStringRequireUtf8(); 82 | 83 | upstream_ = s; 84 | break; 85 | } 86 | case 50: { 87 | java.lang.String s = input.readStringRequireUtf8(); 88 | 89 | upstreamAuth_ = s; 90 | break; 91 | } 92 | } 93 | } 94 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 95 | throw e.setUnfinishedMessage(this); 96 | } catch (java.io.IOException e) { 97 | throw new com.google.protobuf.InvalidProtocolBufferException( 98 | e).setUnfinishedMessage(this); 99 | } finally { 100 | this.unknownFields = unknownFields.build(); 101 | makeExtensionsImmutable(); 102 | } 103 | } 104 | public static final com.google.protobuf.Descriptors.Descriptor 105 | getDescriptor() { 106 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStartRequest_descriptor; 107 | } 108 | 109 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 110 | internalGetFieldAccessorTable() { 111 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStartRequest_fieldAccessorTable 112 | .ensureFieldAccessorsInitialized( 113 | com.deep007.mitmproxyjava.MitmproxyStartRequest.class, com.deep007.mitmproxyjava.MitmproxyStartRequest.Builder.class); 114 | } 115 | 116 | public static final int BIND_FIELD_NUMBER = 1; 117 | private volatile java.lang.Object bind_; 118 | /** 119 | * string bind = 1; 120 | */ 121 | public java.lang.String getBind() { 122 | java.lang.Object ref = bind_; 123 | if (ref instanceof java.lang.String) { 124 | return (java.lang.String) ref; 125 | } else { 126 | com.google.protobuf.ByteString bs = 127 | (com.google.protobuf.ByteString) ref; 128 | java.lang.String s = bs.toStringUtf8(); 129 | bind_ = s; 130 | return s; 131 | } 132 | } 133 | /** 134 | * string bind = 1; 135 | */ 136 | public com.google.protobuf.ByteString 137 | getBindBytes() { 138 | java.lang.Object ref = bind_; 139 | if (ref instanceof java.lang.String) { 140 | com.google.protobuf.ByteString b = 141 | com.google.protobuf.ByteString.copyFromUtf8( 142 | (java.lang.String) ref); 143 | bind_ = b; 144 | return b; 145 | } else { 146 | return (com.google.protobuf.ByteString) ref; 147 | } 148 | } 149 | 150 | public static final int PORT_FIELD_NUMBER = 2; 151 | private int port_; 152 | /** 153 | * int32 port = 2; 154 | */ 155 | public int getPort() { 156 | return port_; 157 | } 158 | 159 | public static final int CALLBACKSERVERADDR_FIELD_NUMBER = 3; 160 | private volatile java.lang.Object callbackServerAddr_; 161 | /** 162 | * string callbackServerAddr = 3; 163 | */ 164 | public java.lang.String getCallbackServerAddr() { 165 | java.lang.Object ref = callbackServerAddr_; 166 | if (ref instanceof java.lang.String) { 167 | return (java.lang.String) ref; 168 | } else { 169 | com.google.protobuf.ByteString bs = 170 | (com.google.protobuf.ByteString) ref; 171 | java.lang.String s = bs.toStringUtf8(); 172 | callbackServerAddr_ = s; 173 | return s; 174 | } 175 | } 176 | /** 177 | * string callbackServerAddr = 3; 178 | */ 179 | public com.google.protobuf.ByteString 180 | getCallbackServerAddrBytes() { 181 | java.lang.Object ref = callbackServerAddr_; 182 | if (ref instanceof java.lang.String) { 183 | com.google.protobuf.ByteString b = 184 | com.google.protobuf.ByteString.copyFromUtf8( 185 | (java.lang.String) ref); 186 | callbackServerAddr_ = b; 187 | return b; 188 | } else { 189 | return (com.google.protobuf.ByteString) ref; 190 | } 191 | } 192 | 193 | public static final int CALLBACKSERVERPORT_FIELD_NUMBER = 4; 194 | private int callbackServerPort_; 195 | /** 196 | * int32 callbackServerPort = 4; 197 | */ 198 | public int getCallbackServerPort() { 199 | return callbackServerPort_; 200 | } 201 | 202 | public static final int UPSTREAM_FIELD_NUMBER = 5; 203 | private volatile java.lang.Object upstream_; 204 | /** 205 | * string upstream = 5; 206 | */ 207 | public java.lang.String getUpstream() { 208 | java.lang.Object ref = upstream_; 209 | if (ref instanceof java.lang.String) { 210 | return (java.lang.String) ref; 211 | } else { 212 | com.google.protobuf.ByteString bs = 213 | (com.google.protobuf.ByteString) ref; 214 | java.lang.String s = bs.toStringUtf8(); 215 | upstream_ = s; 216 | return s; 217 | } 218 | } 219 | /** 220 | * string upstream = 5; 221 | */ 222 | public com.google.protobuf.ByteString 223 | getUpstreamBytes() { 224 | java.lang.Object ref = upstream_; 225 | if (ref instanceof java.lang.String) { 226 | com.google.protobuf.ByteString b = 227 | com.google.protobuf.ByteString.copyFromUtf8( 228 | (java.lang.String) ref); 229 | upstream_ = b; 230 | return b; 231 | } else { 232 | return (com.google.protobuf.ByteString) ref; 233 | } 234 | } 235 | 236 | public static final int UPSTREAMAUTH_FIELD_NUMBER = 6; 237 | private volatile java.lang.Object upstreamAuth_; 238 | /** 239 | * string upstreamAuth = 6; 240 | */ 241 | public java.lang.String getUpstreamAuth() { 242 | java.lang.Object ref = upstreamAuth_; 243 | if (ref instanceof java.lang.String) { 244 | return (java.lang.String) ref; 245 | } else { 246 | com.google.protobuf.ByteString bs = 247 | (com.google.protobuf.ByteString) ref; 248 | java.lang.String s = bs.toStringUtf8(); 249 | upstreamAuth_ = s; 250 | return s; 251 | } 252 | } 253 | /** 254 | * string upstreamAuth = 6; 255 | */ 256 | public com.google.protobuf.ByteString 257 | getUpstreamAuthBytes() { 258 | java.lang.Object ref = upstreamAuth_; 259 | if (ref instanceof java.lang.String) { 260 | com.google.protobuf.ByteString b = 261 | com.google.protobuf.ByteString.copyFromUtf8( 262 | (java.lang.String) ref); 263 | upstreamAuth_ = b; 264 | return b; 265 | } else { 266 | return (com.google.protobuf.ByteString) ref; 267 | } 268 | } 269 | 270 | private byte memoizedIsInitialized = -1; 271 | public final boolean isInitialized() { 272 | byte isInitialized = memoizedIsInitialized; 273 | if (isInitialized == 1) return true; 274 | if (isInitialized == 0) return false; 275 | 276 | memoizedIsInitialized = 1; 277 | return true; 278 | } 279 | 280 | public void writeTo(com.google.protobuf.CodedOutputStream output) 281 | throws java.io.IOException { 282 | if (!getBindBytes().isEmpty()) { 283 | com.google.protobuf.GeneratedMessageV3.writeString(output, 1, bind_); 284 | } 285 | if (port_ != 0) { 286 | output.writeInt32(2, port_); 287 | } 288 | if (!getCallbackServerAddrBytes().isEmpty()) { 289 | com.google.protobuf.GeneratedMessageV3.writeString(output, 3, callbackServerAddr_); 290 | } 291 | if (callbackServerPort_ != 0) { 292 | output.writeInt32(4, callbackServerPort_); 293 | } 294 | if (!getUpstreamBytes().isEmpty()) { 295 | com.google.protobuf.GeneratedMessageV3.writeString(output, 5, upstream_); 296 | } 297 | if (!getUpstreamAuthBytes().isEmpty()) { 298 | com.google.protobuf.GeneratedMessageV3.writeString(output, 6, upstreamAuth_); 299 | } 300 | unknownFields.writeTo(output); 301 | } 302 | 303 | public int getSerializedSize() { 304 | int size = memoizedSize; 305 | if (size != -1) return size; 306 | 307 | size = 0; 308 | if (!getBindBytes().isEmpty()) { 309 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, bind_); 310 | } 311 | if (port_ != 0) { 312 | size += com.google.protobuf.CodedOutputStream 313 | .computeInt32Size(2, port_); 314 | } 315 | if (!getCallbackServerAddrBytes().isEmpty()) { 316 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, callbackServerAddr_); 317 | } 318 | if (callbackServerPort_ != 0) { 319 | size += com.google.protobuf.CodedOutputStream 320 | .computeInt32Size(4, callbackServerPort_); 321 | } 322 | if (!getUpstreamBytes().isEmpty()) { 323 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, upstream_); 324 | } 325 | if (!getUpstreamAuthBytes().isEmpty()) { 326 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, upstreamAuth_); 327 | } 328 | size += unknownFields.getSerializedSize(); 329 | memoizedSize = size; 330 | return size; 331 | } 332 | 333 | @java.lang.Override 334 | public boolean equals(final java.lang.Object obj) { 335 | if (obj == this) { 336 | return true; 337 | } 338 | if (!(obj instanceof com.deep007.mitmproxyjava.MitmproxyStartRequest)) { 339 | return super.equals(obj); 340 | } 341 | com.deep007.mitmproxyjava.MitmproxyStartRequest other = (com.deep007.mitmproxyjava.MitmproxyStartRequest) obj; 342 | 343 | boolean result = true; 344 | result = result && getBind() 345 | .equals(other.getBind()); 346 | result = result && (getPort() 347 | == other.getPort()); 348 | result = result && getCallbackServerAddr() 349 | .equals(other.getCallbackServerAddr()); 350 | result = result && (getCallbackServerPort() 351 | == other.getCallbackServerPort()); 352 | result = result && getUpstream() 353 | .equals(other.getUpstream()); 354 | result = result && getUpstreamAuth() 355 | .equals(other.getUpstreamAuth()); 356 | result = result && unknownFields.equals(other.unknownFields); 357 | return result; 358 | } 359 | 360 | @java.lang.Override 361 | public int hashCode() { 362 | if (memoizedHashCode != 0) { 363 | return memoizedHashCode; 364 | } 365 | int hash = 41; 366 | hash = (19 * hash) + getDescriptor().hashCode(); 367 | hash = (37 * hash) + BIND_FIELD_NUMBER; 368 | hash = (53 * hash) + getBind().hashCode(); 369 | hash = (37 * hash) + PORT_FIELD_NUMBER; 370 | hash = (53 * hash) + getPort(); 371 | hash = (37 * hash) + CALLBACKSERVERADDR_FIELD_NUMBER; 372 | hash = (53 * hash) + getCallbackServerAddr().hashCode(); 373 | hash = (37 * hash) + CALLBACKSERVERPORT_FIELD_NUMBER; 374 | hash = (53 * hash) + getCallbackServerPort(); 375 | hash = (37 * hash) + UPSTREAM_FIELD_NUMBER; 376 | hash = (53 * hash) + getUpstream().hashCode(); 377 | hash = (37 * hash) + UPSTREAMAUTH_FIELD_NUMBER; 378 | hash = (53 * hash) + getUpstreamAuth().hashCode(); 379 | hash = (29 * hash) + unknownFields.hashCode(); 380 | memoizedHashCode = hash; 381 | return hash; 382 | } 383 | 384 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseFrom( 385 | java.nio.ByteBuffer data) 386 | throws com.google.protobuf.InvalidProtocolBufferException { 387 | return PARSER.parseFrom(data); 388 | } 389 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseFrom( 390 | java.nio.ByteBuffer data, 391 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 392 | throws com.google.protobuf.InvalidProtocolBufferException { 393 | return PARSER.parseFrom(data, extensionRegistry); 394 | } 395 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseFrom( 396 | com.google.protobuf.ByteString data) 397 | throws com.google.protobuf.InvalidProtocolBufferException { 398 | return PARSER.parseFrom(data); 399 | } 400 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseFrom( 401 | com.google.protobuf.ByteString data, 402 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 403 | throws com.google.protobuf.InvalidProtocolBufferException { 404 | return PARSER.parseFrom(data, extensionRegistry); 405 | } 406 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseFrom(byte[] data) 407 | throws com.google.protobuf.InvalidProtocolBufferException { 408 | return PARSER.parseFrom(data); 409 | } 410 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseFrom( 411 | byte[] data, 412 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 413 | throws com.google.protobuf.InvalidProtocolBufferException { 414 | return PARSER.parseFrom(data, extensionRegistry); 415 | } 416 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseFrom(java.io.InputStream input) 417 | throws java.io.IOException { 418 | return com.google.protobuf.GeneratedMessageV3 419 | .parseWithIOException(PARSER, input); 420 | } 421 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseFrom( 422 | java.io.InputStream input, 423 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 424 | throws java.io.IOException { 425 | return com.google.protobuf.GeneratedMessageV3 426 | .parseWithIOException(PARSER, input, extensionRegistry); 427 | } 428 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseDelimitedFrom(java.io.InputStream input) 429 | throws java.io.IOException { 430 | return com.google.protobuf.GeneratedMessageV3 431 | .parseDelimitedWithIOException(PARSER, input); 432 | } 433 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseDelimitedFrom( 434 | java.io.InputStream input, 435 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 436 | throws java.io.IOException { 437 | return com.google.protobuf.GeneratedMessageV3 438 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 439 | } 440 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseFrom( 441 | com.google.protobuf.CodedInputStream input) 442 | throws java.io.IOException { 443 | return com.google.protobuf.GeneratedMessageV3 444 | .parseWithIOException(PARSER, input); 445 | } 446 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest parseFrom( 447 | com.google.protobuf.CodedInputStream input, 448 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 449 | throws java.io.IOException { 450 | return com.google.protobuf.GeneratedMessageV3 451 | .parseWithIOException(PARSER, input, extensionRegistry); 452 | } 453 | 454 | public Builder newBuilderForType() { return newBuilder(); } 455 | public static Builder newBuilder() { 456 | return DEFAULT_INSTANCE.toBuilder(); 457 | } 458 | public static Builder newBuilder(com.deep007.mitmproxyjava.MitmproxyStartRequest prototype) { 459 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 460 | } 461 | public Builder toBuilder() { 462 | return this == DEFAULT_INSTANCE 463 | ? new Builder() : new Builder().mergeFrom(this); 464 | } 465 | 466 | @java.lang.Override 467 | protected Builder newBuilderForType( 468 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 469 | Builder builder = new Builder(parent); 470 | return builder; 471 | } 472 | /** 473 | * Protobuf type {@code mitm.MitmproxyStartRequest} 474 | */ 475 | public static final class Builder extends 476 | com.google.protobuf.GeneratedMessageV3.Builder implements 477 | // @@protoc_insertion_point(builder_implements:mitm.MitmproxyStartRequest) 478 | com.deep007.mitmproxyjava.MitmproxyStartRequestOrBuilder { 479 | public static final com.google.protobuf.Descriptors.Descriptor 480 | getDescriptor() { 481 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStartRequest_descriptor; 482 | } 483 | 484 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 485 | internalGetFieldAccessorTable() { 486 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStartRequest_fieldAccessorTable 487 | .ensureFieldAccessorsInitialized( 488 | com.deep007.mitmproxyjava.MitmproxyStartRequest.class, com.deep007.mitmproxyjava.MitmproxyStartRequest.Builder.class); 489 | } 490 | 491 | // Construct using com.deep007.mitmproxyjava.MitmproxyStartRequest.newBuilder() 492 | private Builder() { 493 | maybeForceBuilderInitialization(); 494 | } 495 | 496 | private Builder( 497 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 498 | super(parent); 499 | maybeForceBuilderInitialization(); 500 | } 501 | private void maybeForceBuilderInitialization() { 502 | if (com.google.protobuf.GeneratedMessageV3 503 | .alwaysUseFieldBuilders) { 504 | } 505 | } 506 | public Builder clear() { 507 | super.clear(); 508 | bind_ = ""; 509 | 510 | port_ = 0; 511 | 512 | callbackServerAddr_ = ""; 513 | 514 | callbackServerPort_ = 0; 515 | 516 | upstream_ = ""; 517 | 518 | upstreamAuth_ = ""; 519 | 520 | return this; 521 | } 522 | 523 | public com.google.protobuf.Descriptors.Descriptor 524 | getDescriptorForType() { 525 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStartRequest_descriptor; 526 | } 527 | 528 | public com.deep007.mitmproxyjava.MitmproxyStartRequest getDefaultInstanceForType() { 529 | return com.deep007.mitmproxyjava.MitmproxyStartRequest.getDefaultInstance(); 530 | } 531 | 532 | public com.deep007.mitmproxyjava.MitmproxyStartRequest build() { 533 | com.deep007.mitmproxyjava.MitmproxyStartRequest result = buildPartial(); 534 | if (!result.isInitialized()) { 535 | throw newUninitializedMessageException(result); 536 | } 537 | return result; 538 | } 539 | 540 | public com.deep007.mitmproxyjava.MitmproxyStartRequest buildPartial() { 541 | com.deep007.mitmproxyjava.MitmproxyStartRequest result = new com.deep007.mitmproxyjava.MitmproxyStartRequest(this); 542 | result.bind_ = bind_; 543 | result.port_ = port_; 544 | result.callbackServerAddr_ = callbackServerAddr_; 545 | result.callbackServerPort_ = callbackServerPort_; 546 | result.upstream_ = upstream_; 547 | result.upstreamAuth_ = upstreamAuth_; 548 | onBuilt(); 549 | return result; 550 | } 551 | 552 | public Builder clone() { 553 | return (Builder) super.clone(); 554 | } 555 | public Builder setField( 556 | com.google.protobuf.Descriptors.FieldDescriptor field, 557 | java.lang.Object value) { 558 | return (Builder) super.setField(field, value); 559 | } 560 | public Builder clearField( 561 | com.google.protobuf.Descriptors.FieldDescriptor field) { 562 | return (Builder) super.clearField(field); 563 | } 564 | public Builder clearOneof( 565 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 566 | return (Builder) super.clearOneof(oneof); 567 | } 568 | public Builder setRepeatedField( 569 | com.google.protobuf.Descriptors.FieldDescriptor field, 570 | int index, java.lang.Object value) { 571 | return (Builder) super.setRepeatedField(field, index, value); 572 | } 573 | public Builder addRepeatedField( 574 | com.google.protobuf.Descriptors.FieldDescriptor field, 575 | java.lang.Object value) { 576 | return (Builder) super.addRepeatedField(field, value); 577 | } 578 | public Builder mergeFrom(com.google.protobuf.Message other) { 579 | if (other instanceof com.deep007.mitmproxyjava.MitmproxyStartRequest) { 580 | return mergeFrom((com.deep007.mitmproxyjava.MitmproxyStartRequest)other); 581 | } else { 582 | super.mergeFrom(other); 583 | return this; 584 | } 585 | } 586 | 587 | public Builder mergeFrom(com.deep007.mitmproxyjava.MitmproxyStartRequest other) { 588 | if (other == com.deep007.mitmproxyjava.MitmproxyStartRequest.getDefaultInstance()) return this; 589 | if (!other.getBind().isEmpty()) { 590 | bind_ = other.bind_; 591 | onChanged(); 592 | } 593 | if (other.getPort() != 0) { 594 | setPort(other.getPort()); 595 | } 596 | if (!other.getCallbackServerAddr().isEmpty()) { 597 | callbackServerAddr_ = other.callbackServerAddr_; 598 | onChanged(); 599 | } 600 | if (other.getCallbackServerPort() != 0) { 601 | setCallbackServerPort(other.getCallbackServerPort()); 602 | } 603 | if (!other.getUpstream().isEmpty()) { 604 | upstream_ = other.upstream_; 605 | onChanged(); 606 | } 607 | if (!other.getUpstreamAuth().isEmpty()) { 608 | upstreamAuth_ = other.upstreamAuth_; 609 | onChanged(); 610 | } 611 | this.mergeUnknownFields(other.unknownFields); 612 | onChanged(); 613 | return this; 614 | } 615 | 616 | public final boolean isInitialized() { 617 | return true; 618 | } 619 | 620 | public Builder mergeFrom( 621 | com.google.protobuf.CodedInputStream input, 622 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 623 | throws java.io.IOException { 624 | com.deep007.mitmproxyjava.MitmproxyStartRequest parsedMessage = null; 625 | try { 626 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 627 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 628 | parsedMessage = (com.deep007.mitmproxyjava.MitmproxyStartRequest) e.getUnfinishedMessage(); 629 | throw e.unwrapIOException(); 630 | } finally { 631 | if (parsedMessage != null) { 632 | mergeFrom(parsedMessage); 633 | } 634 | } 635 | return this; 636 | } 637 | 638 | private java.lang.Object bind_ = ""; 639 | /** 640 | * string bind = 1; 641 | */ 642 | public java.lang.String getBind() { 643 | java.lang.Object ref = bind_; 644 | if (!(ref instanceof java.lang.String)) { 645 | com.google.protobuf.ByteString bs = 646 | (com.google.protobuf.ByteString) ref; 647 | java.lang.String s = bs.toStringUtf8(); 648 | bind_ = s; 649 | return s; 650 | } else { 651 | return (java.lang.String) ref; 652 | } 653 | } 654 | /** 655 | * string bind = 1; 656 | */ 657 | public com.google.protobuf.ByteString 658 | getBindBytes() { 659 | java.lang.Object ref = bind_; 660 | if (ref instanceof String) { 661 | com.google.protobuf.ByteString b = 662 | com.google.protobuf.ByteString.copyFromUtf8( 663 | (java.lang.String) ref); 664 | bind_ = b; 665 | return b; 666 | } else { 667 | return (com.google.protobuf.ByteString) ref; 668 | } 669 | } 670 | /** 671 | * string bind = 1; 672 | */ 673 | public Builder setBind( 674 | java.lang.String value) { 675 | if (value == null) { 676 | throw new NullPointerException(); 677 | } 678 | 679 | bind_ = value; 680 | onChanged(); 681 | return this; 682 | } 683 | /** 684 | * string bind = 1; 685 | */ 686 | public Builder clearBind() { 687 | 688 | bind_ = getDefaultInstance().getBind(); 689 | onChanged(); 690 | return this; 691 | } 692 | /** 693 | * string bind = 1; 694 | */ 695 | public Builder setBindBytes( 696 | com.google.protobuf.ByteString value) { 697 | if (value == null) { 698 | throw new NullPointerException(); 699 | } 700 | checkByteStringIsUtf8(value); 701 | 702 | bind_ = value; 703 | onChanged(); 704 | return this; 705 | } 706 | 707 | private int port_ ; 708 | /** 709 | * int32 port = 2; 710 | */ 711 | public int getPort() { 712 | return port_; 713 | } 714 | /** 715 | * int32 port = 2; 716 | */ 717 | public Builder setPort(int value) { 718 | 719 | port_ = value; 720 | onChanged(); 721 | return this; 722 | } 723 | /** 724 | * int32 port = 2; 725 | */ 726 | public Builder clearPort() { 727 | 728 | port_ = 0; 729 | onChanged(); 730 | return this; 731 | } 732 | 733 | private java.lang.Object callbackServerAddr_ = ""; 734 | /** 735 | * string callbackServerAddr = 3; 736 | */ 737 | public java.lang.String getCallbackServerAddr() { 738 | java.lang.Object ref = callbackServerAddr_; 739 | if (!(ref instanceof java.lang.String)) { 740 | com.google.protobuf.ByteString bs = 741 | (com.google.protobuf.ByteString) ref; 742 | java.lang.String s = bs.toStringUtf8(); 743 | callbackServerAddr_ = s; 744 | return s; 745 | } else { 746 | return (java.lang.String) ref; 747 | } 748 | } 749 | /** 750 | * string callbackServerAddr = 3; 751 | */ 752 | public com.google.protobuf.ByteString 753 | getCallbackServerAddrBytes() { 754 | java.lang.Object ref = callbackServerAddr_; 755 | if (ref instanceof String) { 756 | com.google.protobuf.ByteString b = 757 | com.google.protobuf.ByteString.copyFromUtf8( 758 | (java.lang.String) ref); 759 | callbackServerAddr_ = b; 760 | return b; 761 | } else { 762 | return (com.google.protobuf.ByteString) ref; 763 | } 764 | } 765 | /** 766 | * string callbackServerAddr = 3; 767 | */ 768 | public Builder setCallbackServerAddr( 769 | java.lang.String value) { 770 | if (value == null) { 771 | throw new NullPointerException(); 772 | } 773 | 774 | callbackServerAddr_ = value; 775 | onChanged(); 776 | return this; 777 | } 778 | /** 779 | * string callbackServerAddr = 3; 780 | */ 781 | public Builder clearCallbackServerAddr() { 782 | 783 | callbackServerAddr_ = getDefaultInstance().getCallbackServerAddr(); 784 | onChanged(); 785 | return this; 786 | } 787 | /** 788 | * string callbackServerAddr = 3; 789 | */ 790 | public Builder setCallbackServerAddrBytes( 791 | com.google.protobuf.ByteString value) { 792 | if (value == null) { 793 | throw new NullPointerException(); 794 | } 795 | checkByteStringIsUtf8(value); 796 | 797 | callbackServerAddr_ = value; 798 | onChanged(); 799 | return this; 800 | } 801 | 802 | private int callbackServerPort_ ; 803 | /** 804 | * int32 callbackServerPort = 4; 805 | */ 806 | public int getCallbackServerPort() { 807 | return callbackServerPort_; 808 | } 809 | /** 810 | * int32 callbackServerPort = 4; 811 | */ 812 | public Builder setCallbackServerPort(int value) { 813 | 814 | callbackServerPort_ = value; 815 | onChanged(); 816 | return this; 817 | } 818 | /** 819 | * int32 callbackServerPort = 4; 820 | */ 821 | public Builder clearCallbackServerPort() { 822 | 823 | callbackServerPort_ = 0; 824 | onChanged(); 825 | return this; 826 | } 827 | 828 | private java.lang.Object upstream_ = ""; 829 | /** 830 | * string upstream = 5; 831 | */ 832 | public java.lang.String getUpstream() { 833 | java.lang.Object ref = upstream_; 834 | if (!(ref instanceof java.lang.String)) { 835 | com.google.protobuf.ByteString bs = 836 | (com.google.protobuf.ByteString) ref; 837 | java.lang.String s = bs.toStringUtf8(); 838 | upstream_ = s; 839 | return s; 840 | } else { 841 | return (java.lang.String) ref; 842 | } 843 | } 844 | /** 845 | * string upstream = 5; 846 | */ 847 | public com.google.protobuf.ByteString 848 | getUpstreamBytes() { 849 | java.lang.Object ref = upstream_; 850 | if (ref instanceof String) { 851 | com.google.protobuf.ByteString b = 852 | com.google.protobuf.ByteString.copyFromUtf8( 853 | (java.lang.String) ref); 854 | upstream_ = b; 855 | return b; 856 | } else { 857 | return (com.google.protobuf.ByteString) ref; 858 | } 859 | } 860 | /** 861 | * string upstream = 5; 862 | */ 863 | public Builder setUpstream( 864 | java.lang.String value) { 865 | if (value == null) { 866 | throw new NullPointerException(); 867 | } 868 | 869 | upstream_ = value; 870 | onChanged(); 871 | return this; 872 | } 873 | /** 874 | * string upstream = 5; 875 | */ 876 | public Builder clearUpstream() { 877 | 878 | upstream_ = getDefaultInstance().getUpstream(); 879 | onChanged(); 880 | return this; 881 | } 882 | /** 883 | * string upstream = 5; 884 | */ 885 | public Builder setUpstreamBytes( 886 | com.google.protobuf.ByteString value) { 887 | if (value == null) { 888 | throw new NullPointerException(); 889 | } 890 | checkByteStringIsUtf8(value); 891 | 892 | upstream_ = value; 893 | onChanged(); 894 | return this; 895 | } 896 | 897 | private java.lang.Object upstreamAuth_ = ""; 898 | /** 899 | * string upstreamAuth = 6; 900 | */ 901 | public java.lang.String getUpstreamAuth() { 902 | java.lang.Object ref = upstreamAuth_; 903 | if (!(ref instanceof java.lang.String)) { 904 | com.google.protobuf.ByteString bs = 905 | (com.google.protobuf.ByteString) ref; 906 | java.lang.String s = bs.toStringUtf8(); 907 | upstreamAuth_ = s; 908 | return s; 909 | } else { 910 | return (java.lang.String) ref; 911 | } 912 | } 913 | /** 914 | * string upstreamAuth = 6; 915 | */ 916 | public com.google.protobuf.ByteString 917 | getUpstreamAuthBytes() { 918 | java.lang.Object ref = upstreamAuth_; 919 | if (ref instanceof String) { 920 | com.google.protobuf.ByteString b = 921 | com.google.protobuf.ByteString.copyFromUtf8( 922 | (java.lang.String) ref); 923 | upstreamAuth_ = b; 924 | return b; 925 | } else { 926 | return (com.google.protobuf.ByteString) ref; 927 | } 928 | } 929 | /** 930 | * string upstreamAuth = 6; 931 | */ 932 | public Builder setUpstreamAuth( 933 | java.lang.String value) { 934 | if (value == null) { 935 | throw new NullPointerException(); 936 | } 937 | 938 | upstreamAuth_ = value; 939 | onChanged(); 940 | return this; 941 | } 942 | /** 943 | * string upstreamAuth = 6; 944 | */ 945 | public Builder clearUpstreamAuth() { 946 | 947 | upstreamAuth_ = getDefaultInstance().getUpstreamAuth(); 948 | onChanged(); 949 | return this; 950 | } 951 | /** 952 | * string upstreamAuth = 6; 953 | */ 954 | public Builder setUpstreamAuthBytes( 955 | com.google.protobuf.ByteString value) { 956 | if (value == null) { 957 | throw new NullPointerException(); 958 | } 959 | checkByteStringIsUtf8(value); 960 | 961 | upstreamAuth_ = value; 962 | onChanged(); 963 | return this; 964 | } 965 | public final Builder setUnknownFields( 966 | final com.google.protobuf.UnknownFieldSet unknownFields) { 967 | return super.setUnknownFieldsProto3(unknownFields); 968 | } 969 | 970 | public final Builder mergeUnknownFields( 971 | final com.google.protobuf.UnknownFieldSet unknownFields) { 972 | return super.mergeUnknownFields(unknownFields); 973 | } 974 | 975 | 976 | // @@protoc_insertion_point(builder_scope:mitm.MitmproxyStartRequest) 977 | } 978 | 979 | // @@protoc_insertion_point(class_scope:mitm.MitmproxyStartRequest) 980 | private static final com.deep007.mitmproxyjava.MitmproxyStartRequest DEFAULT_INSTANCE; 981 | static { 982 | DEFAULT_INSTANCE = new com.deep007.mitmproxyjava.MitmproxyStartRequest(); 983 | } 984 | 985 | public static com.deep007.mitmproxyjava.MitmproxyStartRequest getDefaultInstance() { 986 | return DEFAULT_INSTANCE; 987 | } 988 | 989 | private static final com.google.protobuf.Parser 990 | PARSER = new com.google.protobuf.AbstractParser() { 991 | public MitmproxyStartRequest parsePartialFrom( 992 | com.google.protobuf.CodedInputStream input, 993 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 994 | throws com.google.protobuf.InvalidProtocolBufferException { 995 | return new MitmproxyStartRequest(input, extensionRegistry); 996 | } 997 | }; 998 | 999 | public static com.google.protobuf.Parser parser() { 1000 | return PARSER; 1001 | } 1002 | 1003 | @java.lang.Override 1004 | public com.google.protobuf.Parser getParserForType() { 1005 | return PARSER; 1006 | } 1007 | 1008 | public com.deep007.mitmproxyjava.MitmproxyStartRequest getDefaultInstanceForType() { 1009 | return DEFAULT_INSTANCE; 1010 | } 1011 | 1012 | } 1013 | 1014 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/MitmproxyStartRequestOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | public interface MitmproxyStartRequestOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:mitm.MitmproxyStartRequest) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * string bind = 1; 12 | */ 13 | java.lang.String getBind(); 14 | /** 15 | * string bind = 1; 16 | */ 17 | com.google.protobuf.ByteString 18 | getBindBytes(); 19 | 20 | /** 21 | * int32 port = 2; 22 | */ 23 | int getPort(); 24 | 25 | /** 26 | * string callbackServerAddr = 3; 27 | */ 28 | java.lang.String getCallbackServerAddr(); 29 | /** 30 | * string callbackServerAddr = 3; 31 | */ 32 | com.google.protobuf.ByteString 33 | getCallbackServerAddrBytes(); 34 | 35 | /** 36 | * int32 callbackServerPort = 4; 37 | */ 38 | int getCallbackServerPort(); 39 | 40 | /** 41 | * string upstream = 5; 42 | */ 43 | java.lang.String getUpstream(); 44 | /** 45 | * string upstream = 5; 46 | */ 47 | com.google.protobuf.ByteString 48 | getUpstreamBytes(); 49 | 50 | /** 51 | * string upstreamAuth = 6; 52 | */ 53 | java.lang.String getUpstreamAuth(); 54 | /** 55 | * string upstreamAuth = 6; 56 | */ 57 | com.google.protobuf.ByteString 58 | getUpstreamAuthBytes(); 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/MitmproxyStartResponse.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | /** 7 | * Protobuf type {@code mitm.MitmproxyStartResponse} 8 | */ 9 | public final class MitmproxyStartResponse extends 10 | com.google.protobuf.GeneratedMessageV3 implements 11 | // @@protoc_insertion_point(message_implements:mitm.MitmproxyStartResponse) 12 | MitmproxyStartResponseOrBuilder { 13 | private static final long serialVersionUID = 0L; 14 | // Use MitmproxyStartResponse.newBuilder() to construct. 15 | private MitmproxyStartResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { 16 | super(builder); 17 | } 18 | private MitmproxyStartResponse() { 19 | mitmproxyId_ = ""; 20 | } 21 | 22 | @java.lang.Override 23 | public final com.google.protobuf.UnknownFieldSet 24 | getUnknownFields() { 25 | return this.unknownFields; 26 | } 27 | private MitmproxyStartResponse( 28 | com.google.protobuf.CodedInputStream input, 29 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 30 | throws com.google.protobuf.InvalidProtocolBufferException { 31 | this(); 32 | if (extensionRegistry == null) { 33 | throw new java.lang.NullPointerException(); 34 | } 35 | int mutable_bitField0_ = 0; 36 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 37 | com.google.protobuf.UnknownFieldSet.newBuilder(); 38 | try { 39 | boolean done = false; 40 | while (!done) { 41 | int tag = input.readTag(); 42 | switch (tag) { 43 | case 0: 44 | done = true; 45 | break; 46 | default: { 47 | if (!parseUnknownFieldProto3( 48 | input, unknownFields, extensionRegistry, tag)) { 49 | done = true; 50 | } 51 | break; 52 | } 53 | case 10: { 54 | java.lang.String s = input.readStringRequireUtf8(); 55 | 56 | mitmproxyId_ = s; 57 | break; 58 | } 59 | } 60 | } 61 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 62 | throw e.setUnfinishedMessage(this); 63 | } catch (java.io.IOException e) { 64 | throw new com.google.protobuf.InvalidProtocolBufferException( 65 | e).setUnfinishedMessage(this); 66 | } finally { 67 | this.unknownFields = unknownFields.build(); 68 | makeExtensionsImmutable(); 69 | } 70 | } 71 | public static final com.google.protobuf.Descriptors.Descriptor 72 | getDescriptor() { 73 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStartResponse_descriptor; 74 | } 75 | 76 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 77 | internalGetFieldAccessorTable() { 78 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStartResponse_fieldAccessorTable 79 | .ensureFieldAccessorsInitialized( 80 | com.deep007.mitmproxyjava.MitmproxyStartResponse.class, com.deep007.mitmproxyjava.MitmproxyStartResponse.Builder.class); 81 | } 82 | 83 | public static final int MITMPROXYID_FIELD_NUMBER = 1; 84 | private volatile java.lang.Object mitmproxyId_; 85 | /** 86 | * string mitmproxyId = 1; 87 | */ 88 | public java.lang.String getMitmproxyId() { 89 | java.lang.Object ref = mitmproxyId_; 90 | if (ref instanceof java.lang.String) { 91 | return (java.lang.String) ref; 92 | } else { 93 | com.google.protobuf.ByteString bs = 94 | (com.google.protobuf.ByteString) ref; 95 | java.lang.String s = bs.toStringUtf8(); 96 | mitmproxyId_ = s; 97 | return s; 98 | } 99 | } 100 | /** 101 | * string mitmproxyId = 1; 102 | */ 103 | public com.google.protobuf.ByteString 104 | getMitmproxyIdBytes() { 105 | java.lang.Object ref = mitmproxyId_; 106 | if (ref instanceof java.lang.String) { 107 | com.google.protobuf.ByteString b = 108 | com.google.protobuf.ByteString.copyFromUtf8( 109 | (java.lang.String) ref); 110 | mitmproxyId_ = b; 111 | return b; 112 | } else { 113 | return (com.google.protobuf.ByteString) ref; 114 | } 115 | } 116 | 117 | private byte memoizedIsInitialized = -1; 118 | public final boolean isInitialized() { 119 | byte isInitialized = memoizedIsInitialized; 120 | if (isInitialized == 1) return true; 121 | if (isInitialized == 0) return false; 122 | 123 | memoizedIsInitialized = 1; 124 | return true; 125 | } 126 | 127 | public void writeTo(com.google.protobuf.CodedOutputStream output) 128 | throws java.io.IOException { 129 | if (!getMitmproxyIdBytes().isEmpty()) { 130 | com.google.protobuf.GeneratedMessageV3.writeString(output, 1, mitmproxyId_); 131 | } 132 | unknownFields.writeTo(output); 133 | } 134 | 135 | public int getSerializedSize() { 136 | int size = memoizedSize; 137 | if (size != -1) return size; 138 | 139 | size = 0; 140 | if (!getMitmproxyIdBytes().isEmpty()) { 141 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, mitmproxyId_); 142 | } 143 | size += unknownFields.getSerializedSize(); 144 | memoizedSize = size; 145 | return size; 146 | } 147 | 148 | @java.lang.Override 149 | public boolean equals(final java.lang.Object obj) { 150 | if (obj == this) { 151 | return true; 152 | } 153 | if (!(obj instanceof com.deep007.mitmproxyjava.MitmproxyStartResponse)) { 154 | return super.equals(obj); 155 | } 156 | com.deep007.mitmproxyjava.MitmproxyStartResponse other = (com.deep007.mitmproxyjava.MitmproxyStartResponse) obj; 157 | 158 | boolean result = true; 159 | result = result && getMitmproxyId() 160 | .equals(other.getMitmproxyId()); 161 | result = result && unknownFields.equals(other.unknownFields); 162 | return result; 163 | } 164 | 165 | @java.lang.Override 166 | public int hashCode() { 167 | if (memoizedHashCode != 0) { 168 | return memoizedHashCode; 169 | } 170 | int hash = 41; 171 | hash = (19 * hash) + getDescriptor().hashCode(); 172 | hash = (37 * hash) + MITMPROXYID_FIELD_NUMBER; 173 | hash = (53 * hash) + getMitmproxyId().hashCode(); 174 | hash = (29 * hash) + unknownFields.hashCode(); 175 | memoizedHashCode = hash; 176 | return hash; 177 | } 178 | 179 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseFrom( 180 | java.nio.ByteBuffer data) 181 | throws com.google.protobuf.InvalidProtocolBufferException { 182 | return PARSER.parseFrom(data); 183 | } 184 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseFrom( 185 | java.nio.ByteBuffer data, 186 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 187 | throws com.google.protobuf.InvalidProtocolBufferException { 188 | return PARSER.parseFrom(data, extensionRegistry); 189 | } 190 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseFrom( 191 | com.google.protobuf.ByteString data) 192 | throws com.google.protobuf.InvalidProtocolBufferException { 193 | return PARSER.parseFrom(data); 194 | } 195 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseFrom( 196 | com.google.protobuf.ByteString data, 197 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 198 | throws com.google.protobuf.InvalidProtocolBufferException { 199 | return PARSER.parseFrom(data, extensionRegistry); 200 | } 201 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseFrom(byte[] data) 202 | throws com.google.protobuf.InvalidProtocolBufferException { 203 | return PARSER.parseFrom(data); 204 | } 205 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseFrom( 206 | byte[] data, 207 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 208 | throws com.google.protobuf.InvalidProtocolBufferException { 209 | return PARSER.parseFrom(data, extensionRegistry); 210 | } 211 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseFrom(java.io.InputStream input) 212 | throws java.io.IOException { 213 | return com.google.protobuf.GeneratedMessageV3 214 | .parseWithIOException(PARSER, input); 215 | } 216 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseFrom( 217 | java.io.InputStream input, 218 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 219 | throws java.io.IOException { 220 | return com.google.protobuf.GeneratedMessageV3 221 | .parseWithIOException(PARSER, input, extensionRegistry); 222 | } 223 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseDelimitedFrom(java.io.InputStream input) 224 | throws java.io.IOException { 225 | return com.google.protobuf.GeneratedMessageV3 226 | .parseDelimitedWithIOException(PARSER, input); 227 | } 228 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseDelimitedFrom( 229 | java.io.InputStream input, 230 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 231 | throws java.io.IOException { 232 | return com.google.protobuf.GeneratedMessageV3 233 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 234 | } 235 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseFrom( 236 | com.google.protobuf.CodedInputStream input) 237 | throws java.io.IOException { 238 | return com.google.protobuf.GeneratedMessageV3 239 | .parseWithIOException(PARSER, input); 240 | } 241 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse parseFrom( 242 | com.google.protobuf.CodedInputStream input, 243 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 244 | throws java.io.IOException { 245 | return com.google.protobuf.GeneratedMessageV3 246 | .parseWithIOException(PARSER, input, extensionRegistry); 247 | } 248 | 249 | public Builder newBuilderForType() { return newBuilder(); } 250 | public static Builder newBuilder() { 251 | return DEFAULT_INSTANCE.toBuilder(); 252 | } 253 | public static Builder newBuilder(com.deep007.mitmproxyjava.MitmproxyStartResponse prototype) { 254 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 255 | } 256 | public Builder toBuilder() { 257 | return this == DEFAULT_INSTANCE 258 | ? new Builder() : new Builder().mergeFrom(this); 259 | } 260 | 261 | @java.lang.Override 262 | protected Builder newBuilderForType( 263 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 264 | Builder builder = new Builder(parent); 265 | return builder; 266 | } 267 | /** 268 | * Protobuf type {@code mitm.MitmproxyStartResponse} 269 | */ 270 | public static final class Builder extends 271 | com.google.protobuf.GeneratedMessageV3.Builder implements 272 | // @@protoc_insertion_point(builder_implements:mitm.MitmproxyStartResponse) 273 | com.deep007.mitmproxyjava.MitmproxyStartResponseOrBuilder { 274 | public static final com.google.protobuf.Descriptors.Descriptor 275 | getDescriptor() { 276 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStartResponse_descriptor; 277 | } 278 | 279 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 280 | internalGetFieldAccessorTable() { 281 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStartResponse_fieldAccessorTable 282 | .ensureFieldAccessorsInitialized( 283 | com.deep007.mitmproxyjava.MitmproxyStartResponse.class, com.deep007.mitmproxyjava.MitmproxyStartResponse.Builder.class); 284 | } 285 | 286 | // Construct using com.deep007.mitmproxyjava.MitmproxyStartResponse.newBuilder() 287 | private Builder() { 288 | maybeForceBuilderInitialization(); 289 | } 290 | 291 | private Builder( 292 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 293 | super(parent); 294 | maybeForceBuilderInitialization(); 295 | } 296 | private void maybeForceBuilderInitialization() { 297 | if (com.google.protobuf.GeneratedMessageV3 298 | .alwaysUseFieldBuilders) { 299 | } 300 | } 301 | public Builder clear() { 302 | super.clear(); 303 | mitmproxyId_ = ""; 304 | 305 | return this; 306 | } 307 | 308 | public com.google.protobuf.Descriptors.Descriptor 309 | getDescriptorForType() { 310 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStartResponse_descriptor; 311 | } 312 | 313 | public com.deep007.mitmproxyjava.MitmproxyStartResponse getDefaultInstanceForType() { 314 | return com.deep007.mitmproxyjava.MitmproxyStartResponse.getDefaultInstance(); 315 | } 316 | 317 | public com.deep007.mitmproxyjava.MitmproxyStartResponse build() { 318 | com.deep007.mitmproxyjava.MitmproxyStartResponse result = buildPartial(); 319 | if (!result.isInitialized()) { 320 | throw newUninitializedMessageException(result); 321 | } 322 | return result; 323 | } 324 | 325 | public com.deep007.mitmproxyjava.MitmproxyStartResponse buildPartial() { 326 | com.deep007.mitmproxyjava.MitmproxyStartResponse result = new com.deep007.mitmproxyjava.MitmproxyStartResponse(this); 327 | result.mitmproxyId_ = mitmproxyId_; 328 | onBuilt(); 329 | return result; 330 | } 331 | 332 | public Builder clone() { 333 | return (Builder) super.clone(); 334 | } 335 | public Builder setField( 336 | com.google.protobuf.Descriptors.FieldDescriptor field, 337 | java.lang.Object value) { 338 | return (Builder) super.setField(field, value); 339 | } 340 | public Builder clearField( 341 | com.google.protobuf.Descriptors.FieldDescriptor field) { 342 | return (Builder) super.clearField(field); 343 | } 344 | public Builder clearOneof( 345 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 346 | return (Builder) super.clearOneof(oneof); 347 | } 348 | public Builder setRepeatedField( 349 | com.google.protobuf.Descriptors.FieldDescriptor field, 350 | int index, java.lang.Object value) { 351 | return (Builder) super.setRepeatedField(field, index, value); 352 | } 353 | public Builder addRepeatedField( 354 | com.google.protobuf.Descriptors.FieldDescriptor field, 355 | java.lang.Object value) { 356 | return (Builder) super.addRepeatedField(field, value); 357 | } 358 | public Builder mergeFrom(com.google.protobuf.Message other) { 359 | if (other instanceof com.deep007.mitmproxyjava.MitmproxyStartResponse) { 360 | return mergeFrom((com.deep007.mitmproxyjava.MitmproxyStartResponse)other); 361 | } else { 362 | super.mergeFrom(other); 363 | return this; 364 | } 365 | } 366 | 367 | public Builder mergeFrom(com.deep007.mitmproxyjava.MitmproxyStartResponse other) { 368 | if (other == com.deep007.mitmproxyjava.MitmproxyStartResponse.getDefaultInstance()) return this; 369 | if (!other.getMitmproxyId().isEmpty()) { 370 | mitmproxyId_ = other.mitmproxyId_; 371 | onChanged(); 372 | } 373 | this.mergeUnknownFields(other.unknownFields); 374 | onChanged(); 375 | return this; 376 | } 377 | 378 | public final boolean isInitialized() { 379 | return true; 380 | } 381 | 382 | public Builder mergeFrom( 383 | com.google.protobuf.CodedInputStream input, 384 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 385 | throws java.io.IOException { 386 | com.deep007.mitmproxyjava.MitmproxyStartResponse parsedMessage = null; 387 | try { 388 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 389 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 390 | parsedMessage = (com.deep007.mitmproxyjava.MitmproxyStartResponse) e.getUnfinishedMessage(); 391 | throw e.unwrapIOException(); 392 | } finally { 393 | if (parsedMessage != null) { 394 | mergeFrom(parsedMessage); 395 | } 396 | } 397 | return this; 398 | } 399 | 400 | private java.lang.Object mitmproxyId_ = ""; 401 | /** 402 | * string mitmproxyId = 1; 403 | */ 404 | public java.lang.String getMitmproxyId() { 405 | java.lang.Object ref = mitmproxyId_; 406 | if (!(ref instanceof java.lang.String)) { 407 | com.google.protobuf.ByteString bs = 408 | (com.google.protobuf.ByteString) ref; 409 | java.lang.String s = bs.toStringUtf8(); 410 | mitmproxyId_ = s; 411 | return s; 412 | } else { 413 | return (java.lang.String) ref; 414 | } 415 | } 416 | /** 417 | * string mitmproxyId = 1; 418 | */ 419 | public com.google.protobuf.ByteString 420 | getMitmproxyIdBytes() { 421 | java.lang.Object ref = mitmproxyId_; 422 | if (ref instanceof String) { 423 | com.google.protobuf.ByteString b = 424 | com.google.protobuf.ByteString.copyFromUtf8( 425 | (java.lang.String) ref); 426 | mitmproxyId_ = b; 427 | return b; 428 | } else { 429 | return (com.google.protobuf.ByteString) ref; 430 | } 431 | } 432 | /** 433 | * string mitmproxyId = 1; 434 | */ 435 | public Builder setMitmproxyId( 436 | java.lang.String value) { 437 | if (value == null) { 438 | throw new NullPointerException(); 439 | } 440 | 441 | mitmproxyId_ = value; 442 | onChanged(); 443 | return this; 444 | } 445 | /** 446 | * string mitmproxyId = 1; 447 | */ 448 | public Builder clearMitmproxyId() { 449 | 450 | mitmproxyId_ = getDefaultInstance().getMitmproxyId(); 451 | onChanged(); 452 | return this; 453 | } 454 | /** 455 | * string mitmproxyId = 1; 456 | */ 457 | public Builder setMitmproxyIdBytes( 458 | com.google.protobuf.ByteString value) { 459 | if (value == null) { 460 | throw new NullPointerException(); 461 | } 462 | checkByteStringIsUtf8(value); 463 | 464 | mitmproxyId_ = value; 465 | onChanged(); 466 | return this; 467 | } 468 | public final Builder setUnknownFields( 469 | final com.google.protobuf.UnknownFieldSet unknownFields) { 470 | return super.setUnknownFieldsProto3(unknownFields); 471 | } 472 | 473 | public final Builder mergeUnknownFields( 474 | final com.google.protobuf.UnknownFieldSet unknownFields) { 475 | return super.mergeUnknownFields(unknownFields); 476 | } 477 | 478 | 479 | // @@protoc_insertion_point(builder_scope:mitm.MitmproxyStartResponse) 480 | } 481 | 482 | // @@protoc_insertion_point(class_scope:mitm.MitmproxyStartResponse) 483 | private static final com.deep007.mitmproxyjava.MitmproxyStartResponse DEFAULT_INSTANCE; 484 | static { 485 | DEFAULT_INSTANCE = new com.deep007.mitmproxyjava.MitmproxyStartResponse(); 486 | } 487 | 488 | public static com.deep007.mitmproxyjava.MitmproxyStartResponse getDefaultInstance() { 489 | return DEFAULT_INSTANCE; 490 | } 491 | 492 | private static final com.google.protobuf.Parser 493 | PARSER = new com.google.protobuf.AbstractParser() { 494 | public MitmproxyStartResponse parsePartialFrom( 495 | com.google.protobuf.CodedInputStream input, 496 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 497 | throws com.google.protobuf.InvalidProtocolBufferException { 498 | return new MitmproxyStartResponse(input, extensionRegistry); 499 | } 500 | }; 501 | 502 | public static com.google.protobuf.Parser parser() { 503 | return PARSER; 504 | } 505 | 506 | @java.lang.Override 507 | public com.google.protobuf.Parser getParserForType() { 508 | return PARSER; 509 | } 510 | 511 | public com.deep007.mitmproxyjava.MitmproxyStartResponse getDefaultInstanceForType() { 512 | return DEFAULT_INSTANCE; 513 | } 514 | 515 | } 516 | 517 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/MitmproxyStartResponseOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | public interface MitmproxyStartResponseOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:mitm.MitmproxyStartResponse) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * string mitmproxyId = 1; 12 | */ 13 | java.lang.String getMitmproxyId(); 14 | /** 15 | * string mitmproxyId = 1; 16 | */ 17 | com.google.protobuf.ByteString 18 | getMitmproxyIdBytes(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/MitmproxyStopRequest.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | /** 7 | * Protobuf type {@code mitm.MitmproxyStopRequest} 8 | */ 9 | public final class MitmproxyStopRequest extends 10 | com.google.protobuf.GeneratedMessageV3 implements 11 | // @@protoc_insertion_point(message_implements:mitm.MitmproxyStopRequest) 12 | MitmproxyStopRequestOrBuilder { 13 | private static final long serialVersionUID = 0L; 14 | // Use MitmproxyStopRequest.newBuilder() to construct. 15 | private MitmproxyStopRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { 16 | super(builder); 17 | } 18 | private MitmproxyStopRequest() { 19 | mitmproxyId_ = ""; 20 | } 21 | 22 | @java.lang.Override 23 | public final com.google.protobuf.UnknownFieldSet 24 | getUnknownFields() { 25 | return this.unknownFields; 26 | } 27 | private MitmproxyStopRequest( 28 | com.google.protobuf.CodedInputStream input, 29 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 30 | throws com.google.protobuf.InvalidProtocolBufferException { 31 | this(); 32 | if (extensionRegistry == null) { 33 | throw new java.lang.NullPointerException(); 34 | } 35 | int mutable_bitField0_ = 0; 36 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 37 | com.google.protobuf.UnknownFieldSet.newBuilder(); 38 | try { 39 | boolean done = false; 40 | while (!done) { 41 | int tag = input.readTag(); 42 | switch (tag) { 43 | case 0: 44 | done = true; 45 | break; 46 | default: { 47 | if (!parseUnknownFieldProto3( 48 | input, unknownFields, extensionRegistry, tag)) { 49 | done = true; 50 | } 51 | break; 52 | } 53 | case 10: { 54 | java.lang.String s = input.readStringRequireUtf8(); 55 | 56 | mitmproxyId_ = s; 57 | break; 58 | } 59 | } 60 | } 61 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 62 | throw e.setUnfinishedMessage(this); 63 | } catch (java.io.IOException e) { 64 | throw new com.google.protobuf.InvalidProtocolBufferException( 65 | e).setUnfinishedMessage(this); 66 | } finally { 67 | this.unknownFields = unknownFields.build(); 68 | makeExtensionsImmutable(); 69 | } 70 | } 71 | public static final com.google.protobuf.Descriptors.Descriptor 72 | getDescriptor() { 73 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStopRequest_descriptor; 74 | } 75 | 76 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 77 | internalGetFieldAccessorTable() { 78 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStopRequest_fieldAccessorTable 79 | .ensureFieldAccessorsInitialized( 80 | com.deep007.mitmproxyjava.MitmproxyStopRequest.class, com.deep007.mitmproxyjava.MitmproxyStopRequest.Builder.class); 81 | } 82 | 83 | public static final int MITMPROXYID_FIELD_NUMBER = 1; 84 | private volatile java.lang.Object mitmproxyId_; 85 | /** 86 | * string mitmproxyId = 1; 87 | */ 88 | public java.lang.String getMitmproxyId() { 89 | java.lang.Object ref = mitmproxyId_; 90 | if (ref instanceof java.lang.String) { 91 | return (java.lang.String) ref; 92 | } else { 93 | com.google.protobuf.ByteString bs = 94 | (com.google.protobuf.ByteString) ref; 95 | java.lang.String s = bs.toStringUtf8(); 96 | mitmproxyId_ = s; 97 | return s; 98 | } 99 | } 100 | /** 101 | * string mitmproxyId = 1; 102 | */ 103 | public com.google.protobuf.ByteString 104 | getMitmproxyIdBytes() { 105 | java.lang.Object ref = mitmproxyId_; 106 | if (ref instanceof java.lang.String) { 107 | com.google.protobuf.ByteString b = 108 | com.google.protobuf.ByteString.copyFromUtf8( 109 | (java.lang.String) ref); 110 | mitmproxyId_ = b; 111 | return b; 112 | } else { 113 | return (com.google.protobuf.ByteString) ref; 114 | } 115 | } 116 | 117 | private byte memoizedIsInitialized = -1; 118 | public final boolean isInitialized() { 119 | byte isInitialized = memoizedIsInitialized; 120 | if (isInitialized == 1) return true; 121 | if (isInitialized == 0) return false; 122 | 123 | memoizedIsInitialized = 1; 124 | return true; 125 | } 126 | 127 | public void writeTo(com.google.protobuf.CodedOutputStream output) 128 | throws java.io.IOException { 129 | if (!getMitmproxyIdBytes().isEmpty()) { 130 | com.google.protobuf.GeneratedMessageV3.writeString(output, 1, mitmproxyId_); 131 | } 132 | unknownFields.writeTo(output); 133 | } 134 | 135 | public int getSerializedSize() { 136 | int size = memoizedSize; 137 | if (size != -1) return size; 138 | 139 | size = 0; 140 | if (!getMitmproxyIdBytes().isEmpty()) { 141 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, mitmproxyId_); 142 | } 143 | size += unknownFields.getSerializedSize(); 144 | memoizedSize = size; 145 | return size; 146 | } 147 | 148 | @java.lang.Override 149 | public boolean equals(final java.lang.Object obj) { 150 | if (obj == this) { 151 | return true; 152 | } 153 | if (!(obj instanceof com.deep007.mitmproxyjava.MitmproxyStopRequest)) { 154 | return super.equals(obj); 155 | } 156 | com.deep007.mitmproxyjava.MitmproxyStopRequest other = (com.deep007.mitmproxyjava.MitmproxyStopRequest) obj; 157 | 158 | boolean result = true; 159 | result = result && getMitmproxyId() 160 | .equals(other.getMitmproxyId()); 161 | result = result && unknownFields.equals(other.unknownFields); 162 | return result; 163 | } 164 | 165 | @java.lang.Override 166 | public int hashCode() { 167 | if (memoizedHashCode != 0) { 168 | return memoizedHashCode; 169 | } 170 | int hash = 41; 171 | hash = (19 * hash) + getDescriptor().hashCode(); 172 | hash = (37 * hash) + MITMPROXYID_FIELD_NUMBER; 173 | hash = (53 * hash) + getMitmproxyId().hashCode(); 174 | hash = (29 * hash) + unknownFields.hashCode(); 175 | memoizedHashCode = hash; 176 | return hash; 177 | } 178 | 179 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseFrom( 180 | java.nio.ByteBuffer data) 181 | throws com.google.protobuf.InvalidProtocolBufferException { 182 | return PARSER.parseFrom(data); 183 | } 184 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseFrom( 185 | java.nio.ByteBuffer data, 186 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 187 | throws com.google.protobuf.InvalidProtocolBufferException { 188 | return PARSER.parseFrom(data, extensionRegistry); 189 | } 190 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseFrom( 191 | com.google.protobuf.ByteString data) 192 | throws com.google.protobuf.InvalidProtocolBufferException { 193 | return PARSER.parseFrom(data); 194 | } 195 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseFrom( 196 | com.google.protobuf.ByteString data, 197 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 198 | throws com.google.protobuf.InvalidProtocolBufferException { 199 | return PARSER.parseFrom(data, extensionRegistry); 200 | } 201 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseFrom(byte[] data) 202 | throws com.google.protobuf.InvalidProtocolBufferException { 203 | return PARSER.parseFrom(data); 204 | } 205 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseFrom( 206 | byte[] data, 207 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 208 | throws com.google.protobuf.InvalidProtocolBufferException { 209 | return PARSER.parseFrom(data, extensionRegistry); 210 | } 211 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseFrom(java.io.InputStream input) 212 | throws java.io.IOException { 213 | return com.google.protobuf.GeneratedMessageV3 214 | .parseWithIOException(PARSER, input); 215 | } 216 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseFrom( 217 | java.io.InputStream input, 218 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 219 | throws java.io.IOException { 220 | return com.google.protobuf.GeneratedMessageV3 221 | .parseWithIOException(PARSER, input, extensionRegistry); 222 | } 223 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseDelimitedFrom(java.io.InputStream input) 224 | throws java.io.IOException { 225 | return com.google.protobuf.GeneratedMessageV3 226 | .parseDelimitedWithIOException(PARSER, input); 227 | } 228 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseDelimitedFrom( 229 | java.io.InputStream input, 230 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 231 | throws java.io.IOException { 232 | return com.google.protobuf.GeneratedMessageV3 233 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 234 | } 235 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseFrom( 236 | com.google.protobuf.CodedInputStream input) 237 | throws java.io.IOException { 238 | return com.google.protobuf.GeneratedMessageV3 239 | .parseWithIOException(PARSER, input); 240 | } 241 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest parseFrom( 242 | com.google.protobuf.CodedInputStream input, 243 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 244 | throws java.io.IOException { 245 | return com.google.protobuf.GeneratedMessageV3 246 | .parseWithIOException(PARSER, input, extensionRegistry); 247 | } 248 | 249 | public Builder newBuilderForType() { return newBuilder(); } 250 | public static Builder newBuilder() { 251 | return DEFAULT_INSTANCE.toBuilder(); 252 | } 253 | public static Builder newBuilder(com.deep007.mitmproxyjava.MitmproxyStopRequest prototype) { 254 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 255 | } 256 | public Builder toBuilder() { 257 | return this == DEFAULT_INSTANCE 258 | ? new Builder() : new Builder().mergeFrom(this); 259 | } 260 | 261 | @java.lang.Override 262 | protected Builder newBuilderForType( 263 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 264 | Builder builder = new Builder(parent); 265 | return builder; 266 | } 267 | /** 268 | * Protobuf type {@code mitm.MitmproxyStopRequest} 269 | */ 270 | public static final class Builder extends 271 | com.google.protobuf.GeneratedMessageV3.Builder implements 272 | // @@protoc_insertion_point(builder_implements:mitm.MitmproxyStopRequest) 273 | com.deep007.mitmproxyjava.MitmproxyStopRequestOrBuilder { 274 | public static final com.google.protobuf.Descriptors.Descriptor 275 | getDescriptor() { 276 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStopRequest_descriptor; 277 | } 278 | 279 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 280 | internalGetFieldAccessorTable() { 281 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStopRequest_fieldAccessorTable 282 | .ensureFieldAccessorsInitialized( 283 | com.deep007.mitmproxyjava.MitmproxyStopRequest.class, com.deep007.mitmproxyjava.MitmproxyStopRequest.Builder.class); 284 | } 285 | 286 | // Construct using com.deep007.mitmproxyjava.MitmproxyStopRequest.newBuilder() 287 | private Builder() { 288 | maybeForceBuilderInitialization(); 289 | } 290 | 291 | private Builder( 292 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 293 | super(parent); 294 | maybeForceBuilderInitialization(); 295 | } 296 | private void maybeForceBuilderInitialization() { 297 | if (com.google.protobuf.GeneratedMessageV3 298 | .alwaysUseFieldBuilders) { 299 | } 300 | } 301 | public Builder clear() { 302 | super.clear(); 303 | mitmproxyId_ = ""; 304 | 305 | return this; 306 | } 307 | 308 | public com.google.protobuf.Descriptors.Descriptor 309 | getDescriptorForType() { 310 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_MitmproxyStopRequest_descriptor; 311 | } 312 | 313 | public com.deep007.mitmproxyjava.MitmproxyStopRequest getDefaultInstanceForType() { 314 | return com.deep007.mitmproxyjava.MitmproxyStopRequest.getDefaultInstance(); 315 | } 316 | 317 | public com.deep007.mitmproxyjava.MitmproxyStopRequest build() { 318 | com.deep007.mitmproxyjava.MitmproxyStopRequest result = buildPartial(); 319 | if (!result.isInitialized()) { 320 | throw newUninitializedMessageException(result); 321 | } 322 | return result; 323 | } 324 | 325 | public com.deep007.mitmproxyjava.MitmproxyStopRequest buildPartial() { 326 | com.deep007.mitmproxyjava.MitmproxyStopRequest result = new com.deep007.mitmproxyjava.MitmproxyStopRequest(this); 327 | result.mitmproxyId_ = mitmproxyId_; 328 | onBuilt(); 329 | return result; 330 | } 331 | 332 | public Builder clone() { 333 | return (Builder) super.clone(); 334 | } 335 | public Builder setField( 336 | com.google.protobuf.Descriptors.FieldDescriptor field, 337 | java.lang.Object value) { 338 | return (Builder) super.setField(field, value); 339 | } 340 | public Builder clearField( 341 | com.google.protobuf.Descriptors.FieldDescriptor field) { 342 | return (Builder) super.clearField(field); 343 | } 344 | public Builder clearOneof( 345 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 346 | return (Builder) super.clearOneof(oneof); 347 | } 348 | public Builder setRepeatedField( 349 | com.google.protobuf.Descriptors.FieldDescriptor field, 350 | int index, java.lang.Object value) { 351 | return (Builder) super.setRepeatedField(field, index, value); 352 | } 353 | public Builder addRepeatedField( 354 | com.google.protobuf.Descriptors.FieldDescriptor field, 355 | java.lang.Object value) { 356 | return (Builder) super.addRepeatedField(field, value); 357 | } 358 | public Builder mergeFrom(com.google.protobuf.Message other) { 359 | if (other instanceof com.deep007.mitmproxyjava.MitmproxyStopRequest) { 360 | return mergeFrom((com.deep007.mitmproxyjava.MitmproxyStopRequest)other); 361 | } else { 362 | super.mergeFrom(other); 363 | return this; 364 | } 365 | } 366 | 367 | public Builder mergeFrom(com.deep007.mitmproxyjava.MitmproxyStopRequest other) { 368 | if (other == com.deep007.mitmproxyjava.MitmproxyStopRequest.getDefaultInstance()) return this; 369 | if (!other.getMitmproxyId().isEmpty()) { 370 | mitmproxyId_ = other.mitmproxyId_; 371 | onChanged(); 372 | } 373 | this.mergeUnknownFields(other.unknownFields); 374 | onChanged(); 375 | return this; 376 | } 377 | 378 | public final boolean isInitialized() { 379 | return true; 380 | } 381 | 382 | public Builder mergeFrom( 383 | com.google.protobuf.CodedInputStream input, 384 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 385 | throws java.io.IOException { 386 | com.deep007.mitmproxyjava.MitmproxyStopRequest parsedMessage = null; 387 | try { 388 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 389 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 390 | parsedMessage = (com.deep007.mitmproxyjava.MitmproxyStopRequest) e.getUnfinishedMessage(); 391 | throw e.unwrapIOException(); 392 | } finally { 393 | if (parsedMessage != null) { 394 | mergeFrom(parsedMessage); 395 | } 396 | } 397 | return this; 398 | } 399 | 400 | private java.lang.Object mitmproxyId_ = ""; 401 | /** 402 | * string mitmproxyId = 1; 403 | */ 404 | public java.lang.String getMitmproxyId() { 405 | java.lang.Object ref = mitmproxyId_; 406 | if (!(ref instanceof java.lang.String)) { 407 | com.google.protobuf.ByteString bs = 408 | (com.google.protobuf.ByteString) ref; 409 | java.lang.String s = bs.toStringUtf8(); 410 | mitmproxyId_ = s; 411 | return s; 412 | } else { 413 | return (java.lang.String) ref; 414 | } 415 | } 416 | /** 417 | * string mitmproxyId = 1; 418 | */ 419 | public com.google.protobuf.ByteString 420 | getMitmproxyIdBytes() { 421 | java.lang.Object ref = mitmproxyId_; 422 | if (ref instanceof String) { 423 | com.google.protobuf.ByteString b = 424 | com.google.protobuf.ByteString.copyFromUtf8( 425 | (java.lang.String) ref); 426 | mitmproxyId_ = b; 427 | return b; 428 | } else { 429 | return (com.google.protobuf.ByteString) ref; 430 | } 431 | } 432 | /** 433 | * string mitmproxyId = 1; 434 | */ 435 | public Builder setMitmproxyId( 436 | java.lang.String value) { 437 | if (value == null) { 438 | throw new NullPointerException(); 439 | } 440 | 441 | mitmproxyId_ = value; 442 | onChanged(); 443 | return this; 444 | } 445 | /** 446 | * string mitmproxyId = 1; 447 | */ 448 | public Builder clearMitmproxyId() { 449 | 450 | mitmproxyId_ = getDefaultInstance().getMitmproxyId(); 451 | onChanged(); 452 | return this; 453 | } 454 | /** 455 | * string mitmproxyId = 1; 456 | */ 457 | public Builder setMitmproxyIdBytes( 458 | com.google.protobuf.ByteString value) { 459 | if (value == null) { 460 | throw new NullPointerException(); 461 | } 462 | checkByteStringIsUtf8(value); 463 | 464 | mitmproxyId_ = value; 465 | onChanged(); 466 | return this; 467 | } 468 | public final Builder setUnknownFields( 469 | final com.google.protobuf.UnknownFieldSet unknownFields) { 470 | return super.setUnknownFieldsProto3(unknownFields); 471 | } 472 | 473 | public final Builder mergeUnknownFields( 474 | final com.google.protobuf.UnknownFieldSet unknownFields) { 475 | return super.mergeUnknownFields(unknownFields); 476 | } 477 | 478 | 479 | // @@protoc_insertion_point(builder_scope:mitm.MitmproxyStopRequest) 480 | } 481 | 482 | // @@protoc_insertion_point(class_scope:mitm.MitmproxyStopRequest) 483 | private static final com.deep007.mitmproxyjava.MitmproxyStopRequest DEFAULT_INSTANCE; 484 | static { 485 | DEFAULT_INSTANCE = new com.deep007.mitmproxyjava.MitmproxyStopRequest(); 486 | } 487 | 488 | public static com.deep007.mitmproxyjava.MitmproxyStopRequest getDefaultInstance() { 489 | return DEFAULT_INSTANCE; 490 | } 491 | 492 | private static final com.google.protobuf.Parser 493 | PARSER = new com.google.protobuf.AbstractParser() { 494 | public MitmproxyStopRequest parsePartialFrom( 495 | com.google.protobuf.CodedInputStream input, 496 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 497 | throws com.google.protobuf.InvalidProtocolBufferException { 498 | return new MitmproxyStopRequest(input, extensionRegistry); 499 | } 500 | }; 501 | 502 | public static com.google.protobuf.Parser parser() { 503 | return PARSER; 504 | } 505 | 506 | @java.lang.Override 507 | public com.google.protobuf.Parser getParserForType() { 508 | return PARSER; 509 | } 510 | 511 | public com.deep007.mitmproxyjava.MitmproxyStopRequest getDefaultInstanceForType() { 512 | return DEFAULT_INSTANCE; 513 | } 514 | 515 | } 516 | 517 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/MitmproxyStopRequestOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | public interface MitmproxyStopRequestOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:mitm.MitmproxyStopRequest) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * string mitmproxyId = 1; 12 | */ 13 | java.lang.String getMitmproxyId(); 14 | /** 15 | * string mitmproxyId = 1; 16 | */ 17 | com.google.protobuf.ByteString 18 | getMitmproxyIdBytes(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/VoidResponse.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | /** 7 | * Protobuf type {@code mitm.VoidResponse} 8 | */ 9 | public final class VoidResponse extends 10 | com.google.protobuf.GeneratedMessageV3 implements 11 | // @@protoc_insertion_point(message_implements:mitm.VoidResponse) 12 | VoidResponseOrBuilder { 13 | private static final long serialVersionUID = 0L; 14 | // Use VoidResponse.newBuilder() to construct. 15 | private VoidResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { 16 | super(builder); 17 | } 18 | private VoidResponse() { 19 | } 20 | 21 | @java.lang.Override 22 | public final com.google.protobuf.UnknownFieldSet 23 | getUnknownFields() { 24 | return this.unknownFields; 25 | } 26 | private VoidResponse( 27 | com.google.protobuf.CodedInputStream input, 28 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 29 | throws com.google.protobuf.InvalidProtocolBufferException { 30 | this(); 31 | if (extensionRegistry == null) { 32 | throw new java.lang.NullPointerException(); 33 | } 34 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 35 | com.google.protobuf.UnknownFieldSet.newBuilder(); 36 | try { 37 | boolean done = false; 38 | while (!done) { 39 | int tag = input.readTag(); 40 | switch (tag) { 41 | case 0: 42 | done = true; 43 | break; 44 | default: { 45 | if (!parseUnknownFieldProto3( 46 | input, unknownFields, extensionRegistry, tag)) { 47 | done = true; 48 | } 49 | break; 50 | } 51 | } 52 | } 53 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 54 | throw e.setUnfinishedMessage(this); 55 | } catch (java.io.IOException e) { 56 | throw new com.google.protobuf.InvalidProtocolBufferException( 57 | e).setUnfinishedMessage(this); 58 | } finally { 59 | this.unknownFields = unknownFields.build(); 60 | makeExtensionsImmutable(); 61 | } 62 | } 63 | public static final com.google.protobuf.Descriptors.Descriptor 64 | getDescriptor() { 65 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_VoidResponse_descriptor; 66 | } 67 | 68 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 69 | internalGetFieldAccessorTable() { 70 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_VoidResponse_fieldAccessorTable 71 | .ensureFieldAccessorsInitialized( 72 | com.deep007.mitmproxyjava.VoidResponse.class, com.deep007.mitmproxyjava.VoidResponse.Builder.class); 73 | } 74 | 75 | private byte memoizedIsInitialized = -1; 76 | public final boolean isInitialized() { 77 | byte isInitialized = memoizedIsInitialized; 78 | if (isInitialized == 1) return true; 79 | if (isInitialized == 0) return false; 80 | 81 | memoizedIsInitialized = 1; 82 | return true; 83 | } 84 | 85 | public void writeTo(com.google.protobuf.CodedOutputStream output) 86 | throws java.io.IOException { 87 | unknownFields.writeTo(output); 88 | } 89 | 90 | public int getSerializedSize() { 91 | int size = memoizedSize; 92 | if (size != -1) return size; 93 | 94 | size = 0; 95 | size += unknownFields.getSerializedSize(); 96 | memoizedSize = size; 97 | return size; 98 | } 99 | 100 | @java.lang.Override 101 | public boolean equals(final java.lang.Object obj) { 102 | if (obj == this) { 103 | return true; 104 | } 105 | if (!(obj instanceof com.deep007.mitmproxyjava.VoidResponse)) { 106 | return super.equals(obj); 107 | } 108 | com.deep007.mitmproxyjava.VoidResponse other = (com.deep007.mitmproxyjava.VoidResponse) obj; 109 | 110 | boolean result = true; 111 | result = result && unknownFields.equals(other.unknownFields); 112 | return result; 113 | } 114 | 115 | @java.lang.Override 116 | public int hashCode() { 117 | if (memoizedHashCode != 0) { 118 | return memoizedHashCode; 119 | } 120 | int hash = 41; 121 | hash = (19 * hash) + getDescriptor().hashCode(); 122 | hash = (29 * hash) + unknownFields.hashCode(); 123 | memoizedHashCode = hash; 124 | return hash; 125 | } 126 | 127 | public static com.deep007.mitmproxyjava.VoidResponse parseFrom( 128 | java.nio.ByteBuffer data) 129 | throws com.google.protobuf.InvalidProtocolBufferException { 130 | return PARSER.parseFrom(data); 131 | } 132 | public static com.deep007.mitmproxyjava.VoidResponse parseFrom( 133 | java.nio.ByteBuffer data, 134 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 135 | throws com.google.protobuf.InvalidProtocolBufferException { 136 | return PARSER.parseFrom(data, extensionRegistry); 137 | } 138 | public static com.deep007.mitmproxyjava.VoidResponse parseFrom( 139 | com.google.protobuf.ByteString data) 140 | throws com.google.protobuf.InvalidProtocolBufferException { 141 | return PARSER.parseFrom(data); 142 | } 143 | public static com.deep007.mitmproxyjava.VoidResponse parseFrom( 144 | com.google.protobuf.ByteString data, 145 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 146 | throws com.google.protobuf.InvalidProtocolBufferException { 147 | return PARSER.parseFrom(data, extensionRegistry); 148 | } 149 | public static com.deep007.mitmproxyjava.VoidResponse parseFrom(byte[] data) 150 | throws com.google.protobuf.InvalidProtocolBufferException { 151 | return PARSER.parseFrom(data); 152 | } 153 | public static com.deep007.mitmproxyjava.VoidResponse parseFrom( 154 | byte[] data, 155 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 156 | throws com.google.protobuf.InvalidProtocolBufferException { 157 | return PARSER.parseFrom(data, extensionRegistry); 158 | } 159 | public static com.deep007.mitmproxyjava.VoidResponse parseFrom(java.io.InputStream input) 160 | throws java.io.IOException { 161 | return com.google.protobuf.GeneratedMessageV3 162 | .parseWithIOException(PARSER, input); 163 | } 164 | public static com.deep007.mitmproxyjava.VoidResponse parseFrom( 165 | java.io.InputStream input, 166 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 167 | throws java.io.IOException { 168 | return com.google.protobuf.GeneratedMessageV3 169 | .parseWithIOException(PARSER, input, extensionRegistry); 170 | } 171 | public static com.deep007.mitmproxyjava.VoidResponse parseDelimitedFrom(java.io.InputStream input) 172 | throws java.io.IOException { 173 | return com.google.protobuf.GeneratedMessageV3 174 | .parseDelimitedWithIOException(PARSER, input); 175 | } 176 | public static com.deep007.mitmproxyjava.VoidResponse parseDelimitedFrom( 177 | java.io.InputStream input, 178 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 179 | throws java.io.IOException { 180 | return com.google.protobuf.GeneratedMessageV3 181 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 182 | } 183 | public static com.deep007.mitmproxyjava.VoidResponse parseFrom( 184 | com.google.protobuf.CodedInputStream input) 185 | throws java.io.IOException { 186 | return com.google.protobuf.GeneratedMessageV3 187 | .parseWithIOException(PARSER, input); 188 | } 189 | public static com.deep007.mitmproxyjava.VoidResponse parseFrom( 190 | com.google.protobuf.CodedInputStream input, 191 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 192 | throws java.io.IOException { 193 | return com.google.protobuf.GeneratedMessageV3 194 | .parseWithIOException(PARSER, input, extensionRegistry); 195 | } 196 | 197 | public Builder newBuilderForType() { return newBuilder(); } 198 | public static Builder newBuilder() { 199 | return DEFAULT_INSTANCE.toBuilder(); 200 | } 201 | public static Builder newBuilder(com.deep007.mitmproxyjava.VoidResponse prototype) { 202 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 203 | } 204 | public Builder toBuilder() { 205 | return this == DEFAULT_INSTANCE 206 | ? new Builder() : new Builder().mergeFrom(this); 207 | } 208 | 209 | @java.lang.Override 210 | protected Builder newBuilderForType( 211 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 212 | Builder builder = new Builder(parent); 213 | return builder; 214 | } 215 | /** 216 | * Protobuf type {@code mitm.VoidResponse} 217 | */ 218 | public static final class Builder extends 219 | com.google.protobuf.GeneratedMessageV3.Builder implements 220 | // @@protoc_insertion_point(builder_implements:mitm.VoidResponse) 221 | com.deep007.mitmproxyjava.VoidResponseOrBuilder { 222 | public static final com.google.protobuf.Descriptors.Descriptor 223 | getDescriptor() { 224 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_VoidResponse_descriptor; 225 | } 226 | 227 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 228 | internalGetFieldAccessorTable() { 229 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_VoidResponse_fieldAccessorTable 230 | .ensureFieldAccessorsInitialized( 231 | com.deep007.mitmproxyjava.VoidResponse.class, com.deep007.mitmproxyjava.VoidResponse.Builder.class); 232 | } 233 | 234 | // Construct using com.deep007.mitmproxyjava.VoidResponse.newBuilder() 235 | private Builder() { 236 | maybeForceBuilderInitialization(); 237 | } 238 | 239 | private Builder( 240 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 241 | super(parent); 242 | maybeForceBuilderInitialization(); 243 | } 244 | private void maybeForceBuilderInitialization() { 245 | if (com.google.protobuf.GeneratedMessageV3 246 | .alwaysUseFieldBuilders) { 247 | } 248 | } 249 | public Builder clear() { 250 | super.clear(); 251 | return this; 252 | } 253 | 254 | public com.google.protobuf.Descriptors.Descriptor 255 | getDescriptorForType() { 256 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.internal_static_mitm_VoidResponse_descriptor; 257 | } 258 | 259 | public com.deep007.mitmproxyjava.VoidResponse getDefaultInstanceForType() { 260 | return com.deep007.mitmproxyjava.VoidResponse.getDefaultInstance(); 261 | } 262 | 263 | public com.deep007.mitmproxyjava.VoidResponse build() { 264 | com.deep007.mitmproxyjava.VoidResponse result = buildPartial(); 265 | if (!result.isInitialized()) { 266 | throw newUninitializedMessageException(result); 267 | } 268 | return result; 269 | } 270 | 271 | public com.deep007.mitmproxyjava.VoidResponse buildPartial() { 272 | com.deep007.mitmproxyjava.VoidResponse result = new com.deep007.mitmproxyjava.VoidResponse(this); 273 | onBuilt(); 274 | return result; 275 | } 276 | 277 | public Builder clone() { 278 | return (Builder) super.clone(); 279 | } 280 | public Builder setField( 281 | com.google.protobuf.Descriptors.FieldDescriptor field, 282 | java.lang.Object value) { 283 | return (Builder) super.setField(field, value); 284 | } 285 | public Builder clearField( 286 | com.google.protobuf.Descriptors.FieldDescriptor field) { 287 | return (Builder) super.clearField(field); 288 | } 289 | public Builder clearOneof( 290 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 291 | return (Builder) super.clearOneof(oneof); 292 | } 293 | public Builder setRepeatedField( 294 | com.google.protobuf.Descriptors.FieldDescriptor field, 295 | int index, java.lang.Object value) { 296 | return (Builder) super.setRepeatedField(field, index, value); 297 | } 298 | public Builder addRepeatedField( 299 | com.google.protobuf.Descriptors.FieldDescriptor field, 300 | java.lang.Object value) { 301 | return (Builder) super.addRepeatedField(field, value); 302 | } 303 | public Builder mergeFrom(com.google.protobuf.Message other) { 304 | if (other instanceof com.deep007.mitmproxyjava.VoidResponse) { 305 | return mergeFrom((com.deep007.mitmproxyjava.VoidResponse)other); 306 | } else { 307 | super.mergeFrom(other); 308 | return this; 309 | } 310 | } 311 | 312 | public Builder mergeFrom(com.deep007.mitmproxyjava.VoidResponse other) { 313 | if (other == com.deep007.mitmproxyjava.VoidResponse.getDefaultInstance()) return this; 314 | this.mergeUnknownFields(other.unknownFields); 315 | onChanged(); 316 | return this; 317 | } 318 | 319 | public final boolean isInitialized() { 320 | return true; 321 | } 322 | 323 | public Builder mergeFrom( 324 | com.google.protobuf.CodedInputStream input, 325 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 326 | throws java.io.IOException { 327 | com.deep007.mitmproxyjava.VoidResponse parsedMessage = null; 328 | try { 329 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 330 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 331 | parsedMessage = (com.deep007.mitmproxyjava.VoidResponse) e.getUnfinishedMessage(); 332 | throw e.unwrapIOException(); 333 | } finally { 334 | if (parsedMessage != null) { 335 | mergeFrom(parsedMessage); 336 | } 337 | } 338 | return this; 339 | } 340 | public final Builder setUnknownFields( 341 | final com.google.protobuf.UnknownFieldSet unknownFields) { 342 | return super.setUnknownFieldsProto3(unknownFields); 343 | } 344 | 345 | public final Builder mergeUnknownFields( 346 | final com.google.protobuf.UnknownFieldSet unknownFields) { 347 | return super.mergeUnknownFields(unknownFields); 348 | } 349 | 350 | 351 | // @@protoc_insertion_point(builder_scope:mitm.VoidResponse) 352 | } 353 | 354 | // @@protoc_insertion_point(class_scope:mitm.VoidResponse) 355 | private static final com.deep007.mitmproxyjava.VoidResponse DEFAULT_INSTANCE; 356 | static { 357 | DEFAULT_INSTANCE = new com.deep007.mitmproxyjava.VoidResponse(); 358 | } 359 | 360 | public static com.deep007.mitmproxyjava.VoidResponse getDefaultInstance() { 361 | return DEFAULT_INSTANCE; 362 | } 363 | 364 | private static final com.google.protobuf.Parser 365 | PARSER = new com.google.protobuf.AbstractParser() { 366 | public VoidResponse parsePartialFrom( 367 | com.google.protobuf.CodedInputStream input, 368 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 369 | throws com.google.protobuf.InvalidProtocolBufferException { 370 | return new VoidResponse(input, extensionRegistry); 371 | } 372 | }; 373 | 374 | public static com.google.protobuf.Parser parser() { 375 | return PARSER; 376 | } 377 | 378 | @java.lang.Override 379 | public com.google.protobuf.Parser getParserForType() { 380 | return PARSER; 381 | } 382 | 383 | public com.deep007.mitmproxyjava.VoidResponse getDefaultInstanceForType() { 384 | return DEFAULT_INSTANCE; 385 | } 386 | 387 | } 388 | 389 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/VoidResponseOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: mitm_hub_client.proto 3 | 4 | package com.deep007.mitmproxyjava; 5 | 6 | public interface VoidResponseOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:mitm.VoidResponse) 8 | com.google.protobuf.MessageOrBuilder { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/filter/Cookie.java: -------------------------------------------------------------------------------- 1 | package com.deep007.mitmproxyjava.filter; 2 | 3 | import java.util.Date; 4 | 5 | 6 | public class Cookie { 7 | 8 | private String name; 9 | 10 | private String value; 11 | 12 | private String domain; 13 | 14 | private String path = "/"; 15 | 16 | private Date expiry; 17 | 18 | private boolean secure; 19 | 20 | private boolean httpOnly; 21 | 22 | public Cookie(){ 23 | } 24 | 25 | public Cookie(String name, String value) { 26 | super(); 27 | this.name = name; 28 | this.value = value; 29 | } 30 | 31 | public Cookie(String name, String value, String domain, String path, Date expiry, boolean secure, 32 | boolean httpOnly) { 33 | this.name = name; 34 | this.value = value; 35 | this.domain = domain; 36 | this.path = path; 37 | this.expiry = expiry; 38 | this.secure = secure; 39 | this.httpOnly = httpOnly; 40 | } 41 | 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | public String getValue() { 47 | return value; 48 | } 49 | 50 | public void setName(String name) { 51 | this.name = name; 52 | } 53 | 54 | public void setValue(String value) { 55 | this.value = value; 56 | } 57 | 58 | public String getDomain() { 59 | return domain; 60 | } 61 | 62 | public void setDomain(String domain) { 63 | this.domain = domain; 64 | } 65 | 66 | public String getPath() { 67 | return path; 68 | } 69 | 70 | public void setPath(String path) { 71 | this.path = path; 72 | } 73 | 74 | public Date getExpiry() { 75 | return expiry; 76 | } 77 | 78 | public void setExpiry(Date expiry) { 79 | this.expiry = expiry; 80 | } 81 | 82 | public void setExpires(Date expiry) { 83 | this.expiry = expiry; 84 | } 85 | 86 | public boolean isSecure() { 87 | return secure; 88 | } 89 | 90 | public void setSecure(boolean secure) { 91 | this.secure = secure; 92 | } 93 | 94 | public boolean isHttpOnly() { 95 | return httpOnly; 96 | } 97 | 98 | public void setHttpOnly(boolean httpOnly) { 99 | this.httpOnly = httpOnly; 100 | } 101 | 102 | 103 | @Override 104 | public String toString() { 105 | return "Cookie [name=" + name + ", value=" + value + ", domain=" + domain + ", path=" + path + ", expiry=" 106 | + expiry + ", secure=" + secure + ", httpOnly=" + httpOnly + "]"; 107 | } 108 | 109 | @Override 110 | public int hashCode() { 111 | final int prime = 31; 112 | int result = 1; 113 | result = prime * result + ((name == null) ? 0 : name.hashCode()); 114 | result = prime * result + ((value == null) ? 0 : value.hashCode()); 115 | return result; 116 | } 117 | 118 | @Override 119 | public boolean equals(Object obj) { 120 | if (this == obj) 121 | return true; 122 | if (obj == null) 123 | return false; 124 | if (getClass() != obj.getClass()) 125 | return false; 126 | Cookie other = (Cookie) obj; 127 | if (name == null) { 128 | if (other.name != null) 129 | return false; 130 | } else if (!name.equals(other.name)) 131 | return false; 132 | if (value == null) { 133 | if (other.value != null) 134 | return false; 135 | } else if (!value.equals(other.value)) 136 | return false; 137 | return true; 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/filter/CookieCollectFilter.java: -------------------------------------------------------------------------------- 1 | package com.deep007.mitmproxyjava.filter; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | import java.util.Set; 6 | import java.util.concurrent.ConcurrentHashMap; 7 | import java.util.regex.Matcher; 8 | import java.util.regex.Pattern; 9 | 10 | import com.deep007.mitmproxyjava.modle.FlowRequest; 11 | import com.deep007.mitmproxyjava.modle.FlowResponse; 12 | import com.google.common.collect.Sets; 13 | 14 | public class CookieCollectFilter implements FlowFilter { 15 | 16 | private Pattern SETCOOKIE_NAME_VALUE_MATCHER = Pattern.compile("([^\\s]+)=([^\\s,;]+)"); 17 | 18 | private Pattern URL_DOMAIN_MATCHER = Pattern.compile("http[s]?://([^\\.]+[^/]+)"); 19 | 20 | public Map catchCookies = new ConcurrentHashMap<>(); 21 | 22 | public String domainFromUrl(String url) { 23 | Matcher sendcookie_domain_matcher = URL_DOMAIN_MATCHER.matcher(url); 24 | if (!sendcookie_domain_matcher.find()) { 25 | System.err.println("从url解析domain失败:"+url); 26 | return "baidu.com"; 27 | } 28 | return sendcookie_domain_matcher.group(1); 29 | } 30 | 31 | @Override 32 | public void filterRequest(FlowRequest flowRequest) { 33 | String sendCookie = flowRequest.getHeaders().get("Cookie"); 34 | if (sendCookie == null || sendCookie.isEmpty()) { 35 | //System.out.println("filterRequest cookie isEmpty"); 36 | //System.out.println(flowRequest.getHeaders().keySet()); 37 | return; 38 | } 39 | String url = flowRequest.getUrl(); 40 | String domain = domainFromUrl(url); 41 | String[] items = sendCookie.split(";"); 42 | for (int i = 0; items != null && i < items.length; i++) { 43 | String item = items[i].trim(); 44 | if (item.contains("=")) { 45 | String[] nameValue = item.split("=", 2); 46 | Cookie cookie = new Cookie(nameValue[0], nameValue[1]); 47 | cookie.setDomain(domain); 48 | catchCookies.put(nameValue[0], cookie); 49 | }else if (!item.isEmpty()) { 50 | //log.warn("sendCookie解析错误:" + item); 51 | } 52 | } 53 | } 54 | 55 | @Override 56 | public void filterResponse(FlowResponse flowResponse) { 57 | String setCookie = flowResponse.getHeader("Set-Cookie"); 58 | if (setCookie == null || setCookie.isEmpty()) { 59 | //System.out.println("filterResponse cookie isEmpty"); 60 | //System.out.println(flowResponse.getHeaders().keySet()); 61 | return; 62 | } 63 | String url = flowResponse.getRequest().getUrl(); 64 | //clueSourceCode=%2A%2300; path=/; domain=.guazi.com, cainfo=%7B%22ca_s%22%3A%22self%22%2C%22ca_n%22%3A%22self%22%2C%22ca_medium%22%3A%22-%22%2C%22ca_term%22%3A%22-%22%2C%22ca_content%22%3A%22-%22%2C%22ca_campaign%22%3A%22-%22%2C%22ca_kw%22%3A%22-%22%2C%22ca_i%22%3A%22-%22%2C%22scode%22%3A%22-%22%2C%22ca_city%22%3A%22bj%22%2C%22guid%22%3A%220a87e81e-abdf-4a7e-c62b-f28209884750%22%2C%22keyword%22%3A%22-%22%2C%22ca_keywordid%22%3A%22-%22%2C%22ca_b%22%3A%22-%22%2C%22ca_a%22%3A%22-%22%2C%22display_finance_flag%22%3A%22-%22%2C%22platform%22%3A%221%22%2C%22version%22%3A1%2C%22client_ab%22%3A%22-%22%2C%22sessionid%22%3A%22ab0ddad4-451e-42a1-f56f-71067cb9e087%22%7D; expires=Wed, 22-Dec-2021 12:01:40 GMT; Max-Age=31536000; path=/; domain=.guazi.com, user_city_id=12; expires=Wed, 23-Dec-2020 12:01:40 GMT; Max-Age=86400; path=/; domain=.guazi.com, preTime=%7B%22last%22%3A1608638500%2C%22this%22%3A1608638500%2C%22pre%22%3A1608638500%7D; expires=Sat, 20-Feb-2021 12:01:40 GMT; Max-Age=5184000; path=/; domain=.guazi.com 65 | String domain = domainFromUrl(url); 66 | Matcher setcookie_name_value_matcher = SETCOOKIE_NAME_VALUE_MATCHER.matcher(setCookie.trim()); 67 | while (setcookie_name_value_matcher.find()) { 68 | String name = setcookie_name_value_matcher.group(1); 69 | if (name.equalsIgnoreCase("path") || name.equalsIgnoreCase("domain") || name.equalsIgnoreCase("expires") || name.equalsIgnoreCase("Max-Age")) { 70 | continue; 71 | } 72 | String value = setcookie_name_value_matcher.group(2); 73 | Cookie cookie = new Cookie(name, value); 74 | cookie.setDomain(domain); 75 | catchCookies.put(name, cookie); 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/filter/FlowFilter.java: -------------------------------------------------------------------------------- 1 | package com.deep007.mitmproxyjava.filter; 2 | 3 | import com.deep007.mitmproxyjava.modle.FlowRequest; 4 | import com.deep007.mitmproxyjava.modle.FlowResponse; 5 | 6 | public interface FlowFilter { 7 | 8 | public void filterRequest(FlowRequest flowRequest) throws Exception; 9 | 10 | public void filterResponse(FlowResponse flowResponse) throws Exception; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/grpc/MitmProxyHubClientServerGrpc.java: -------------------------------------------------------------------------------- 1 | package com.deep007.mitmproxyjava.grpc; 2 | 3 | import static io.grpc.MethodDescriptor.generateFullMethodName; 4 | import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; 5 | import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; 6 | import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; 7 | import static io.grpc.stub.ClientCalls.asyncUnaryCall; 8 | import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; 9 | import static io.grpc.stub.ClientCalls.blockingUnaryCall; 10 | import static io.grpc.stub.ClientCalls.futureUnaryCall; 11 | import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; 12 | import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; 13 | import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; 14 | import static io.grpc.stub.ServerCalls.asyncUnaryCall; 15 | import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; 16 | import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; 17 | 18 | /** 19 | *
 20 |  *java、go、c++客户端回调server实现,它接收mitmproxy流量的回调,修改并返回给python端
 21 |  * 
22 | */ 23 | @javax.annotation.Generated( 24 | value = "by gRPC proto compiler (version 1.15.0)", 25 | comments = "Source: mitm_hub_client.proto") 26 | public final class MitmProxyHubClientServerGrpc { 27 | 28 | private MitmProxyHubClientServerGrpc() {} 29 | 30 | public static final String SERVICE_NAME = "mitm.MitmProxyHubClientServer"; 31 | 32 | // Static method descriptors that strictly reflect the proto. 33 | private static volatile io.grpc.MethodDescriptor getOnMitmRequestMethod; 35 | 36 | @io.grpc.stub.annotations.RpcMethod( 37 | fullMethodName = SERVICE_NAME + '/' + "onMitmRequest", 38 | requestType = com.deep007.mitmproxyjava.MitmRequest.class, 39 | responseType = com.deep007.mitmproxyjava.MitmRequest.class, 40 | methodType = io.grpc.MethodDescriptor.MethodType.UNARY) 41 | public static io.grpc.MethodDescriptor getOnMitmRequestMethod() { 43 | io.grpc.MethodDescriptor getOnMitmRequestMethod; 44 | if ((getOnMitmRequestMethod = MitmProxyHubClientServerGrpc.getOnMitmRequestMethod) == null) { 45 | synchronized (MitmProxyHubClientServerGrpc.class) { 46 | if ((getOnMitmRequestMethod = MitmProxyHubClientServerGrpc.getOnMitmRequestMethod) == null) { 47 | MitmProxyHubClientServerGrpc.getOnMitmRequestMethod = getOnMitmRequestMethod = 48 | io.grpc.MethodDescriptor.newBuilder() 49 | .setType(io.grpc.MethodDescriptor.MethodType.UNARY) 50 | .setFullMethodName(generateFullMethodName( 51 | "mitm.MitmProxyHubClientServer", "onMitmRequest")) 52 | .setSampledToLocalTracing(true) 53 | .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 54 | com.deep007.mitmproxyjava.MitmRequest.getDefaultInstance())) 55 | .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 56 | com.deep007.mitmproxyjava.MitmRequest.getDefaultInstance())) 57 | .setSchemaDescriptor(new MitmProxyHubClientServerMethodDescriptorSupplier("onMitmRequest")) 58 | .build(); 59 | } 60 | } 61 | } 62 | return getOnMitmRequestMethod; 63 | } 64 | 65 | private static volatile io.grpc.MethodDescriptor getOnMitmResponseMethod; 67 | 68 | @io.grpc.stub.annotations.RpcMethod( 69 | fullMethodName = SERVICE_NAME + '/' + "onMitmResponse", 70 | requestType = com.deep007.mitmproxyjava.MitmResponse.class, 71 | responseType = com.deep007.mitmproxyjava.MitmResponse.class, 72 | methodType = io.grpc.MethodDescriptor.MethodType.UNARY) 73 | public static io.grpc.MethodDescriptor getOnMitmResponseMethod() { 75 | io.grpc.MethodDescriptor getOnMitmResponseMethod; 76 | if ((getOnMitmResponseMethod = MitmProxyHubClientServerGrpc.getOnMitmResponseMethod) == null) { 77 | synchronized (MitmProxyHubClientServerGrpc.class) { 78 | if ((getOnMitmResponseMethod = MitmProxyHubClientServerGrpc.getOnMitmResponseMethod) == null) { 79 | MitmProxyHubClientServerGrpc.getOnMitmResponseMethod = getOnMitmResponseMethod = 80 | io.grpc.MethodDescriptor.newBuilder() 81 | .setType(io.grpc.MethodDescriptor.MethodType.UNARY) 82 | .setFullMethodName(generateFullMethodName( 83 | "mitm.MitmProxyHubClientServer", "onMitmResponse")) 84 | .setSampledToLocalTracing(true) 85 | .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 86 | com.deep007.mitmproxyjava.MitmResponse.getDefaultInstance())) 87 | .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 88 | com.deep007.mitmproxyjava.MitmResponse.getDefaultInstance())) 89 | .setSchemaDescriptor(new MitmProxyHubClientServerMethodDescriptorSupplier("onMitmResponse")) 90 | .build(); 91 | } 92 | } 93 | } 94 | return getOnMitmResponseMethod; 95 | } 96 | 97 | /** 98 | * Creates a new async stub that supports all call types for the service 99 | */ 100 | public static MitmProxyHubClientServerStub newStub(io.grpc.Channel channel) { 101 | return new MitmProxyHubClientServerStub(channel); 102 | } 103 | 104 | /** 105 | * Creates a new blocking-style stub that supports unary and streaming output calls on the service 106 | */ 107 | public static MitmProxyHubClientServerBlockingStub newBlockingStub( 108 | io.grpc.Channel channel) { 109 | return new MitmProxyHubClientServerBlockingStub(channel); 110 | } 111 | 112 | /** 113 | * Creates a new ListenableFuture-style stub that supports unary calls on the service 114 | */ 115 | public static MitmProxyHubClientServerFutureStub newFutureStub( 116 | io.grpc.Channel channel) { 117 | return new MitmProxyHubClientServerFutureStub(channel); 118 | } 119 | 120 | /** 121 | *
122 |    *java、go、c++客户端回调server实现,它接收mitmproxy流量的回调,修改并返回给python端
123 |    * 
124 | */ 125 | public static abstract class MitmProxyHubClientServerImplBase implements io.grpc.BindableService { 126 | 127 | /** 128 | */ 129 | public void onMitmRequest(com.deep007.mitmproxyjava.MitmRequest request, 130 | io.grpc.stub.StreamObserver responseObserver) { 131 | asyncUnimplementedUnaryCall(getOnMitmRequestMethod(), responseObserver); 132 | } 133 | 134 | /** 135 | */ 136 | public void onMitmResponse(com.deep007.mitmproxyjava.MitmResponse request, 137 | io.grpc.stub.StreamObserver responseObserver) { 138 | asyncUnimplementedUnaryCall(getOnMitmResponseMethod(), responseObserver); 139 | } 140 | 141 | @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { 142 | return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) 143 | .addMethod( 144 | getOnMitmRequestMethod(), 145 | asyncUnaryCall( 146 | new MethodHandlers< 147 | com.deep007.mitmproxyjava.MitmRequest, 148 | com.deep007.mitmproxyjava.MitmRequest>( 149 | this, METHODID_ON_MITM_REQUEST))) 150 | .addMethod( 151 | getOnMitmResponseMethod(), 152 | asyncUnaryCall( 153 | new MethodHandlers< 154 | com.deep007.mitmproxyjava.MitmResponse, 155 | com.deep007.mitmproxyjava.MitmResponse>( 156 | this, METHODID_ON_MITM_RESPONSE))) 157 | .build(); 158 | } 159 | } 160 | 161 | /** 162 | *
163 |    *java、go、c++客户端回调server实现,它接收mitmproxy流量的回调,修改并返回给python端
164 |    * 
165 | */ 166 | public static final class MitmProxyHubClientServerStub extends io.grpc.stub.AbstractStub { 167 | private MitmProxyHubClientServerStub(io.grpc.Channel channel) { 168 | super(channel); 169 | } 170 | 171 | private MitmProxyHubClientServerStub(io.grpc.Channel channel, 172 | io.grpc.CallOptions callOptions) { 173 | super(channel, callOptions); 174 | } 175 | 176 | @java.lang.Override 177 | protected MitmProxyHubClientServerStub build(io.grpc.Channel channel, 178 | io.grpc.CallOptions callOptions) { 179 | return new MitmProxyHubClientServerStub(channel, callOptions); 180 | } 181 | 182 | /** 183 | */ 184 | public void onMitmRequest(com.deep007.mitmproxyjava.MitmRequest request, 185 | io.grpc.stub.StreamObserver responseObserver) { 186 | asyncUnaryCall( 187 | getChannel().newCall(getOnMitmRequestMethod(), getCallOptions()), request, responseObserver); 188 | } 189 | 190 | /** 191 | */ 192 | public void onMitmResponse(com.deep007.mitmproxyjava.MitmResponse request, 193 | io.grpc.stub.StreamObserver responseObserver) { 194 | asyncUnaryCall( 195 | getChannel().newCall(getOnMitmResponseMethod(), getCallOptions()), request, responseObserver); 196 | } 197 | } 198 | 199 | /** 200 | *
201 |    *java、go、c++客户端回调server实现,它接收mitmproxy流量的回调,修改并返回给python端
202 |    * 
203 | */ 204 | public static final class MitmProxyHubClientServerBlockingStub extends io.grpc.stub.AbstractStub { 205 | private MitmProxyHubClientServerBlockingStub(io.grpc.Channel channel) { 206 | super(channel); 207 | } 208 | 209 | private MitmProxyHubClientServerBlockingStub(io.grpc.Channel channel, 210 | io.grpc.CallOptions callOptions) { 211 | super(channel, callOptions); 212 | } 213 | 214 | @java.lang.Override 215 | protected MitmProxyHubClientServerBlockingStub build(io.grpc.Channel channel, 216 | io.grpc.CallOptions callOptions) { 217 | return new MitmProxyHubClientServerBlockingStub(channel, callOptions); 218 | } 219 | 220 | /** 221 | */ 222 | public com.deep007.mitmproxyjava.MitmRequest onMitmRequest(com.deep007.mitmproxyjava.MitmRequest request) { 223 | return blockingUnaryCall( 224 | getChannel(), getOnMitmRequestMethod(), getCallOptions(), request); 225 | } 226 | 227 | /** 228 | */ 229 | public com.deep007.mitmproxyjava.MitmResponse onMitmResponse(com.deep007.mitmproxyjava.MitmResponse request) { 230 | return blockingUnaryCall( 231 | getChannel(), getOnMitmResponseMethod(), getCallOptions(), request); 232 | } 233 | } 234 | 235 | /** 236 | *
237 |    *java、go、c++客户端回调server实现,它接收mitmproxy流量的回调,修改并返回给python端
238 |    * 
239 | */ 240 | public static final class MitmProxyHubClientServerFutureStub extends io.grpc.stub.AbstractStub { 241 | private MitmProxyHubClientServerFutureStub(io.grpc.Channel channel) { 242 | super(channel); 243 | } 244 | 245 | private MitmProxyHubClientServerFutureStub(io.grpc.Channel channel, 246 | io.grpc.CallOptions callOptions) { 247 | super(channel, callOptions); 248 | } 249 | 250 | @java.lang.Override 251 | protected MitmProxyHubClientServerFutureStub build(io.grpc.Channel channel, 252 | io.grpc.CallOptions callOptions) { 253 | return new MitmProxyHubClientServerFutureStub(channel, callOptions); 254 | } 255 | 256 | /** 257 | */ 258 | public com.google.common.util.concurrent.ListenableFuture onMitmRequest( 259 | com.deep007.mitmproxyjava.MitmRequest request) { 260 | return futureUnaryCall( 261 | getChannel().newCall(getOnMitmRequestMethod(), getCallOptions()), request); 262 | } 263 | 264 | /** 265 | */ 266 | public com.google.common.util.concurrent.ListenableFuture onMitmResponse( 267 | com.deep007.mitmproxyjava.MitmResponse request) { 268 | return futureUnaryCall( 269 | getChannel().newCall(getOnMitmResponseMethod(), getCallOptions()), request); 270 | } 271 | } 272 | 273 | private static final int METHODID_ON_MITM_REQUEST = 0; 274 | private static final int METHODID_ON_MITM_RESPONSE = 1; 275 | 276 | private static final class MethodHandlers implements 277 | io.grpc.stub.ServerCalls.UnaryMethod, 278 | io.grpc.stub.ServerCalls.ServerStreamingMethod, 279 | io.grpc.stub.ServerCalls.ClientStreamingMethod, 280 | io.grpc.stub.ServerCalls.BidiStreamingMethod { 281 | private final MitmProxyHubClientServerImplBase serviceImpl; 282 | private final int methodId; 283 | 284 | MethodHandlers(MitmProxyHubClientServerImplBase serviceImpl, int methodId) { 285 | this.serviceImpl = serviceImpl; 286 | this.methodId = methodId; 287 | } 288 | 289 | @java.lang.Override 290 | @java.lang.SuppressWarnings("unchecked") 291 | public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { 292 | switch (methodId) { 293 | case METHODID_ON_MITM_REQUEST: 294 | serviceImpl.onMitmRequest((com.deep007.mitmproxyjava.MitmRequest) request, 295 | (io.grpc.stub.StreamObserver) responseObserver); 296 | break; 297 | case METHODID_ON_MITM_RESPONSE: 298 | serviceImpl.onMitmResponse((com.deep007.mitmproxyjava.MitmResponse) request, 299 | (io.grpc.stub.StreamObserver) responseObserver); 300 | break; 301 | default: 302 | throw new AssertionError(); 303 | } 304 | } 305 | 306 | @java.lang.Override 307 | @java.lang.SuppressWarnings("unchecked") 308 | public io.grpc.stub.StreamObserver invoke( 309 | io.grpc.stub.StreamObserver responseObserver) { 310 | switch (methodId) { 311 | default: 312 | throw new AssertionError(); 313 | } 314 | } 315 | } 316 | 317 | private static abstract class MitmProxyHubClientServerBaseDescriptorSupplier 318 | implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { 319 | MitmProxyHubClientServerBaseDescriptorSupplier() {} 320 | 321 | @java.lang.Override 322 | public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { 323 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.getDescriptor(); 324 | } 325 | 326 | @java.lang.Override 327 | public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { 328 | return getFileDescriptor().findServiceByName("MitmProxyHubClientServer"); 329 | } 330 | } 331 | 332 | private static final class MitmProxyHubClientServerFileDescriptorSupplier 333 | extends MitmProxyHubClientServerBaseDescriptorSupplier { 334 | MitmProxyHubClientServerFileDescriptorSupplier() {} 335 | } 336 | 337 | private static final class MitmProxyHubClientServerMethodDescriptorSupplier 338 | extends MitmProxyHubClientServerBaseDescriptorSupplier 339 | implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { 340 | private final String methodName; 341 | 342 | MitmProxyHubClientServerMethodDescriptorSupplier(String methodName) { 343 | this.methodName = methodName; 344 | } 345 | 346 | @java.lang.Override 347 | public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { 348 | return getServiceDescriptor().findMethodByName(methodName); 349 | } 350 | } 351 | 352 | private static volatile io.grpc.ServiceDescriptor serviceDescriptor; 353 | 354 | public static io.grpc.ServiceDescriptor getServiceDescriptor() { 355 | io.grpc.ServiceDescriptor result = serviceDescriptor; 356 | if (result == null) { 357 | synchronized (MitmProxyHubClientServerGrpc.class) { 358 | result = serviceDescriptor; 359 | if (result == null) { 360 | serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) 361 | .setSchemaDescriptor(new MitmProxyHubClientServerFileDescriptorSupplier()) 362 | .addMethod(getOnMitmRequestMethod()) 363 | .addMethod(getOnMitmResponseMethod()) 364 | .build(); 365 | } 366 | } 367 | } 368 | return result; 369 | } 370 | } 371 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/grpc/MitmProxyHubServerGrpc.java: -------------------------------------------------------------------------------- 1 | package com.deep007.mitmproxyjava.grpc; 2 | 3 | import static io.grpc.MethodDescriptor.generateFullMethodName; 4 | import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; 5 | import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; 6 | import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; 7 | import static io.grpc.stub.ClientCalls.asyncUnaryCall; 8 | import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; 9 | import static io.grpc.stub.ClientCalls.blockingUnaryCall; 10 | import static io.grpc.stub.ClientCalls.futureUnaryCall; 11 | import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; 12 | import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; 13 | import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; 14 | import static io.grpc.stub.ServerCalls.asyncUnaryCall; 15 | import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; 16 | import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; 17 | 18 | /** 19 | *
 20 |  *MitmProxyHubServer负责启动mitmproxy和通知回调client端
 21 |  * 
22 | */ 23 | @javax.annotation.Generated( 24 | value = "by gRPC proto compiler (version 1.15.0)", 25 | comments = "Source: mitm_hub_client.proto") 26 | public final class MitmProxyHubServerGrpc { 27 | 28 | private MitmProxyHubServerGrpc() {} 29 | 30 | public static final String SERVICE_NAME = "mitm.MitmProxyHubServer"; 31 | 32 | // Static method descriptors that strictly reflect the proto. 33 | private static volatile io.grpc.MethodDescriptor getStartMethod; 35 | 36 | @io.grpc.stub.annotations.RpcMethod( 37 | fullMethodName = SERVICE_NAME + '/' + "start", 38 | requestType = com.deep007.mitmproxyjava.MitmproxyStartRequest.class, 39 | responseType = com.deep007.mitmproxyjava.MitmproxyStartResponse.class, 40 | methodType = io.grpc.MethodDescriptor.MethodType.UNARY) 41 | public static io.grpc.MethodDescriptor getStartMethod() { 43 | io.grpc.MethodDescriptor getStartMethod; 44 | if ((getStartMethod = MitmProxyHubServerGrpc.getStartMethod) == null) { 45 | synchronized (MitmProxyHubServerGrpc.class) { 46 | if ((getStartMethod = MitmProxyHubServerGrpc.getStartMethod) == null) { 47 | MitmProxyHubServerGrpc.getStartMethod = getStartMethod = 48 | io.grpc.MethodDescriptor.newBuilder() 49 | .setType(io.grpc.MethodDescriptor.MethodType.UNARY) 50 | .setFullMethodName(generateFullMethodName( 51 | "mitm.MitmProxyHubServer", "start")) 52 | .setSampledToLocalTracing(true) 53 | .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 54 | com.deep007.mitmproxyjava.MitmproxyStartRequest.getDefaultInstance())) 55 | .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 56 | com.deep007.mitmproxyjava.MitmproxyStartResponse.getDefaultInstance())) 57 | .setSchemaDescriptor(new MitmProxyHubServerMethodDescriptorSupplier("start")) 58 | .build(); 59 | } 60 | } 61 | } 62 | return getStartMethod; 63 | } 64 | 65 | private static volatile io.grpc.MethodDescriptor getStopMethod; 67 | 68 | @io.grpc.stub.annotations.RpcMethod( 69 | fullMethodName = SERVICE_NAME + '/' + "stop", 70 | requestType = com.deep007.mitmproxyjava.MitmproxyStopRequest.class, 71 | responseType = com.deep007.mitmproxyjava.VoidResponse.class, 72 | methodType = io.grpc.MethodDescriptor.MethodType.UNARY) 73 | public static io.grpc.MethodDescriptor getStopMethod() { 75 | io.grpc.MethodDescriptor getStopMethod; 76 | if ((getStopMethod = MitmProxyHubServerGrpc.getStopMethod) == null) { 77 | synchronized (MitmProxyHubServerGrpc.class) { 78 | if ((getStopMethod = MitmProxyHubServerGrpc.getStopMethod) == null) { 79 | MitmProxyHubServerGrpc.getStopMethod = getStopMethod = 80 | io.grpc.MethodDescriptor.newBuilder() 81 | .setType(io.grpc.MethodDescriptor.MethodType.UNARY) 82 | .setFullMethodName(generateFullMethodName( 83 | "mitm.MitmProxyHubServer", "stop")) 84 | .setSampledToLocalTracing(true) 85 | .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 86 | com.deep007.mitmproxyjava.MitmproxyStopRequest.getDefaultInstance())) 87 | .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( 88 | com.deep007.mitmproxyjava.VoidResponse.getDefaultInstance())) 89 | .setSchemaDescriptor(new MitmProxyHubServerMethodDescriptorSupplier("stop")) 90 | .build(); 91 | } 92 | } 93 | } 94 | return getStopMethod; 95 | } 96 | 97 | /** 98 | * Creates a new async stub that supports all call types for the service 99 | */ 100 | public static MitmProxyHubServerStub newStub(io.grpc.Channel channel) { 101 | return new MitmProxyHubServerStub(channel); 102 | } 103 | 104 | /** 105 | * Creates a new blocking-style stub that supports unary and streaming output calls on the service 106 | */ 107 | public static MitmProxyHubServerBlockingStub newBlockingStub( 108 | io.grpc.Channel channel) { 109 | return new MitmProxyHubServerBlockingStub(channel); 110 | } 111 | 112 | /** 113 | * Creates a new ListenableFuture-style stub that supports unary calls on the service 114 | */ 115 | public static MitmProxyHubServerFutureStub newFutureStub( 116 | io.grpc.Channel channel) { 117 | return new MitmProxyHubServerFutureStub(channel); 118 | } 119 | 120 | /** 121 | *
122 |    *MitmProxyHubServer负责启动mitmproxy和通知回调client端
123 |    * 
124 | */ 125 | public static abstract class MitmProxyHubServerImplBase implements io.grpc.BindableService { 126 | 127 | /** 128 | */ 129 | public void start(com.deep007.mitmproxyjava.MitmproxyStartRequest request, 130 | io.grpc.stub.StreamObserver responseObserver) { 131 | asyncUnimplementedUnaryCall(getStartMethod(), responseObserver); 132 | } 133 | 134 | /** 135 | */ 136 | public void stop(com.deep007.mitmproxyjava.MitmproxyStopRequest request, 137 | io.grpc.stub.StreamObserver responseObserver) { 138 | asyncUnimplementedUnaryCall(getStopMethod(), responseObserver); 139 | } 140 | 141 | @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { 142 | return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) 143 | .addMethod( 144 | getStartMethod(), 145 | asyncUnaryCall( 146 | new MethodHandlers< 147 | com.deep007.mitmproxyjava.MitmproxyStartRequest, 148 | com.deep007.mitmproxyjava.MitmproxyStartResponse>( 149 | this, METHODID_START))) 150 | .addMethod( 151 | getStopMethod(), 152 | asyncUnaryCall( 153 | new MethodHandlers< 154 | com.deep007.mitmproxyjava.MitmproxyStopRequest, 155 | com.deep007.mitmproxyjava.VoidResponse>( 156 | this, METHODID_STOP))) 157 | .build(); 158 | } 159 | } 160 | 161 | /** 162 | *
163 |    *MitmProxyHubServer负责启动mitmproxy和通知回调client端
164 |    * 
165 | */ 166 | public static final class MitmProxyHubServerStub extends io.grpc.stub.AbstractStub { 167 | private MitmProxyHubServerStub(io.grpc.Channel channel) { 168 | super(channel); 169 | } 170 | 171 | private MitmProxyHubServerStub(io.grpc.Channel channel, 172 | io.grpc.CallOptions callOptions) { 173 | super(channel, callOptions); 174 | } 175 | 176 | @java.lang.Override 177 | protected MitmProxyHubServerStub build(io.grpc.Channel channel, 178 | io.grpc.CallOptions callOptions) { 179 | return new MitmProxyHubServerStub(channel, callOptions); 180 | } 181 | 182 | /** 183 | */ 184 | public void start(com.deep007.mitmproxyjava.MitmproxyStartRequest request, 185 | io.grpc.stub.StreamObserver responseObserver) { 186 | asyncUnaryCall( 187 | getChannel().newCall(getStartMethod(), getCallOptions()), request, responseObserver); 188 | } 189 | 190 | /** 191 | */ 192 | public void stop(com.deep007.mitmproxyjava.MitmproxyStopRequest request, 193 | io.grpc.stub.StreamObserver responseObserver) { 194 | asyncUnaryCall( 195 | getChannel().newCall(getStopMethod(), getCallOptions()), request, responseObserver); 196 | } 197 | } 198 | 199 | /** 200 | *
201 |    *MitmProxyHubServer负责启动mitmproxy和通知回调client端
202 |    * 
203 | */ 204 | public static final class MitmProxyHubServerBlockingStub extends io.grpc.stub.AbstractStub { 205 | private MitmProxyHubServerBlockingStub(io.grpc.Channel channel) { 206 | super(channel); 207 | } 208 | 209 | private MitmProxyHubServerBlockingStub(io.grpc.Channel channel, 210 | io.grpc.CallOptions callOptions) { 211 | super(channel, callOptions); 212 | } 213 | 214 | @java.lang.Override 215 | protected MitmProxyHubServerBlockingStub build(io.grpc.Channel channel, 216 | io.grpc.CallOptions callOptions) { 217 | return new MitmProxyHubServerBlockingStub(channel, callOptions); 218 | } 219 | 220 | /** 221 | */ 222 | public com.deep007.mitmproxyjava.MitmproxyStartResponse start(com.deep007.mitmproxyjava.MitmproxyStartRequest request) { 223 | return blockingUnaryCall( 224 | getChannel(), getStartMethod(), getCallOptions(), request); 225 | } 226 | 227 | /** 228 | */ 229 | public com.deep007.mitmproxyjava.VoidResponse stop(com.deep007.mitmproxyjava.MitmproxyStopRequest request) { 230 | return blockingUnaryCall( 231 | getChannel(), getStopMethod(), getCallOptions(), request); 232 | } 233 | } 234 | 235 | /** 236 | *
237 |    *MitmProxyHubServer负责启动mitmproxy和通知回调client端
238 |    * 
239 | */ 240 | public static final class MitmProxyHubServerFutureStub extends io.grpc.stub.AbstractStub { 241 | private MitmProxyHubServerFutureStub(io.grpc.Channel channel) { 242 | super(channel); 243 | } 244 | 245 | private MitmProxyHubServerFutureStub(io.grpc.Channel channel, 246 | io.grpc.CallOptions callOptions) { 247 | super(channel, callOptions); 248 | } 249 | 250 | @java.lang.Override 251 | protected MitmProxyHubServerFutureStub build(io.grpc.Channel channel, 252 | io.grpc.CallOptions callOptions) { 253 | return new MitmProxyHubServerFutureStub(channel, callOptions); 254 | } 255 | 256 | /** 257 | */ 258 | public com.google.common.util.concurrent.ListenableFuture start( 259 | com.deep007.mitmproxyjava.MitmproxyStartRequest request) { 260 | return futureUnaryCall( 261 | getChannel().newCall(getStartMethod(), getCallOptions()), request); 262 | } 263 | 264 | /** 265 | */ 266 | public com.google.common.util.concurrent.ListenableFuture stop( 267 | com.deep007.mitmproxyjava.MitmproxyStopRequest request) { 268 | return futureUnaryCall( 269 | getChannel().newCall(getStopMethod(), getCallOptions()), request); 270 | } 271 | } 272 | 273 | private static final int METHODID_START = 0; 274 | private static final int METHODID_STOP = 1; 275 | 276 | private static final class MethodHandlers implements 277 | io.grpc.stub.ServerCalls.UnaryMethod, 278 | io.grpc.stub.ServerCalls.ServerStreamingMethod, 279 | io.grpc.stub.ServerCalls.ClientStreamingMethod, 280 | io.grpc.stub.ServerCalls.BidiStreamingMethod { 281 | private final MitmProxyHubServerImplBase serviceImpl; 282 | private final int methodId; 283 | 284 | MethodHandlers(MitmProxyHubServerImplBase serviceImpl, int methodId) { 285 | this.serviceImpl = serviceImpl; 286 | this.methodId = methodId; 287 | } 288 | 289 | @java.lang.Override 290 | @java.lang.SuppressWarnings("unchecked") 291 | public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { 292 | switch (methodId) { 293 | case METHODID_START: 294 | serviceImpl.start((com.deep007.mitmproxyjava.MitmproxyStartRequest) request, 295 | (io.grpc.stub.StreamObserver) responseObserver); 296 | break; 297 | case METHODID_STOP: 298 | serviceImpl.stop((com.deep007.mitmproxyjava.MitmproxyStopRequest) request, 299 | (io.grpc.stub.StreamObserver) responseObserver); 300 | break; 301 | default: 302 | throw new AssertionError(); 303 | } 304 | } 305 | 306 | @java.lang.Override 307 | @java.lang.SuppressWarnings("unchecked") 308 | public io.grpc.stub.StreamObserver invoke( 309 | io.grpc.stub.StreamObserver responseObserver) { 310 | switch (methodId) { 311 | default: 312 | throw new AssertionError(); 313 | } 314 | } 315 | } 316 | 317 | private static abstract class MitmProxyHubServerBaseDescriptorSupplier 318 | implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { 319 | MitmProxyHubServerBaseDescriptorSupplier() {} 320 | 321 | @java.lang.Override 322 | public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { 323 | return com.deep007.mitmproxyjava.MitmProxyHubClientServerProto.getDescriptor(); 324 | } 325 | 326 | @java.lang.Override 327 | public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { 328 | return getFileDescriptor().findServiceByName("MitmProxyHubServer"); 329 | } 330 | } 331 | 332 | private static final class MitmProxyHubServerFileDescriptorSupplier 333 | extends MitmProxyHubServerBaseDescriptorSupplier { 334 | MitmProxyHubServerFileDescriptorSupplier() {} 335 | } 336 | 337 | private static final class MitmProxyHubServerMethodDescriptorSupplier 338 | extends MitmProxyHubServerBaseDescriptorSupplier 339 | implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { 340 | private final String methodName; 341 | 342 | MitmProxyHubServerMethodDescriptorSupplier(String methodName) { 343 | this.methodName = methodName; 344 | } 345 | 346 | @java.lang.Override 347 | public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { 348 | return getServiceDescriptor().findMethodByName(methodName); 349 | } 350 | } 351 | 352 | private static volatile io.grpc.ServiceDescriptor serviceDescriptor; 353 | 354 | public static io.grpc.ServiceDescriptor getServiceDescriptor() { 355 | io.grpc.ServiceDescriptor result = serviceDescriptor; 356 | if (result == null) { 357 | synchronized (MitmProxyHubServerGrpc.class) { 358 | result = serviceDescriptor; 359 | if (result == null) { 360 | serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) 361 | .setSchemaDescriptor(new MitmProxyHubServerFileDescriptorSupplier()) 362 | .addMethod(getStartMethod()) 363 | .addMethod(getStopMethod()) 364 | .build(); 365 | } 366 | } 367 | } 368 | return result; 369 | } 370 | } 371 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/grpc/MitmproxyFlowCallBackServer.java: -------------------------------------------------------------------------------- 1 | package com.deep007.mitmproxyjava.grpc; 2 | 3 | import java.lang.reflect.Field; 4 | import java.util.logging.Level; 5 | import java.util.logging.Logger; 6 | 7 | import com.deep007.mitmproxyjava.MitmRequest; 8 | import com.deep007.mitmproxyjava.MitmResponse; 9 | import com.deep007.mitmproxyjava.mitmproxy.RemoteMitmproxy; 10 | import com.deep007.mitmproxyjava.modle.FlowRequest; 11 | import com.deep007.mitmproxyjava.modle.FlowResponse; 12 | 13 | import io.grpc.Server; 14 | import io.grpc.ServerBuilder; 15 | import io.grpc.stub.StreamObserver; 16 | 17 | public class MitmproxyFlowCallBackServer { 18 | 19 | private volatile static MitmproxyFlowCallBackServer mitmFlowCallBackServer; 20 | 21 | /** 22 | * 获取默认的MitmproxyFlowCallBackServer实例,默认的实例启动在60061端口上。如果你想启动在其他端口请使用MitmproxyFlowCallBackServer(int port)构造方法创建 23 | * 并注意维护其生命周期 24 | * @return 25 | */ 26 | public synchronized static MitmproxyFlowCallBackServer getInstance() { 27 | if (mitmFlowCallBackServer == null) { 28 | try { 29 | mitmFlowCallBackServer = new MitmproxyFlowCallBackServer(); 30 | } catch (Exception e) { 31 | e.printStackTrace(); 32 | } 33 | } 34 | return mitmFlowCallBackServer; 35 | } 36 | 37 | private Server server; 38 | 39 | public final int port; 40 | 41 | private boolean isStarted = false; 42 | 43 | public MitmproxyFlowCallBackServer() throws Exception { 44 | this(60061); 45 | } 46 | 47 | 48 | public MitmproxyFlowCallBackServer(int port) throws Exception { 49 | this.port = port; 50 | this.server = ServerBuilder.forPort(port) 51 | .addService(new MonitorServerImpl()) 52 | .build(); 53 | start(); 54 | } 55 | 56 | 57 | public int getPort() { 58 | return port; 59 | } 60 | 61 | private void start() throws Exception { 62 | if (!isStarted) { 63 | server.start(); 64 | Class nettyServerHandlerClass = Class.forName("io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler"); 65 | Field loggerField = nettyServerHandlerClass.getDeclaredField("logger"); 66 | loggerField.setAccessible(true); 67 | java.util.logging.Logger log = (Logger) loggerField.get(null); 68 | log.setLevel(Level.SEVERE); 69 | Runtime.getRuntime().addShutdownHook(new Thread() { 70 | @Override 71 | public void run() { 72 | MitmproxyFlowCallBackServer.this.stop(); 73 | } 74 | }); 75 | isStarted = true; 76 | System.out.println("MitmproxyFlowCallBackServer started on "+ port); 77 | } 78 | 79 | } 80 | 81 | private void stop() { 82 | if (isStarted && server != null) { 83 | server.shutdownNow(); 84 | server = null; 85 | } 86 | } 87 | 88 | private class MonitorServerImpl extends MitmProxyHubClientServerGrpc.MitmProxyHubClientServerImplBase { 89 | 90 | 91 | @Override 92 | public void onMitmRequest(MitmRequest request, StreamObserver responseObserver) { 93 | String mitmproxyId = request.getMitmproxyId(); 94 | System.out.println("remotemitmproxy " + request.getMethod() + " - " + request.getUrl()); 95 | FlowRequest lRequest = FlowRequest.create(request); 96 | RemoteMitmproxy remoteMitmproxy = RemoteMitmproxy.RemoteMitmproxies.get(mitmproxyId); 97 | if (remoteMitmproxy != null) { 98 | remoteMitmproxy.onRequest(lRequest); 99 | } 100 | responseObserver.onNext(lRequest.getMitmRequest()); 101 | responseObserver.onCompleted(); 102 | } 103 | 104 | @Override 105 | public void onMitmResponse(MitmResponse response, StreamObserver responseObserver) { 106 | String mitmproxyId = response.getMitmproxyId(); 107 | RemoteMitmproxy remoteMitmproxy = RemoteMitmproxy.RemoteMitmproxies.get(mitmproxyId); 108 | FlowResponse lResponse = FlowResponse.create(response); 109 | if (remoteMitmproxy != null) { 110 | remoteMitmproxy.onResponse(lResponse); 111 | } 112 | responseObserver.onNext(lResponse.getMitmResponse()); 113 | responseObserver.onCompleted(); 114 | } 115 | 116 | } 117 | 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/mitmproxy/RemoteMitmproxy.java: -------------------------------------------------------------------------------- 1 | package com.deep007.mitmproxyjava.mitmproxy; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.Random; 7 | import java.util.concurrent.ConcurrentHashMap; 8 | 9 | import com.deep007.mitmproxyjava.MitmproxyStartRequest; 10 | import com.deep007.mitmproxyjava.MitmproxyStartResponse; 11 | import com.deep007.mitmproxyjava.MitmproxyStopRequest; 12 | import com.deep007.mitmproxyjava.VoidResponse; 13 | import com.deep007.mitmproxyjava.filter.Cookie; 14 | import com.deep007.mitmproxyjava.filter.CookieCollectFilter; 15 | import com.deep007.mitmproxyjava.filter.FlowFilter; 16 | import com.deep007.mitmproxyjava.grpc.MitmProxyHubServerGrpc; 17 | import com.deep007.mitmproxyjava.grpc.MitmproxyFlowCallBackServer; 18 | import com.deep007.mitmproxyjava.modle.FlowRequest; 19 | import com.deep007.mitmproxyjava.modle.FlowResponse; 20 | 21 | import io.grpc.Channel; 22 | import io.grpc.ManagedChannelBuilder; 23 | 24 | public class RemoteMitmproxy { 25 | 26 | public static final Map RemoteMitmproxies = new ConcurrentHashMap<>(); 27 | 28 | private String mitmproxyHubAddr; 29 | 30 | private int mitmproxyHubPort; 31 | 32 | private String remoteBind; 33 | 34 | private int remoteBindPort; 35 | 36 | private String upstream; 37 | 38 | private String upstreamAuth; 39 | 40 | private volatile String mitmproxyId; 41 | 42 | private MitmProxyHubServerGrpc.MitmProxyHubServerBlockingStub mitmProxyHubServerBlockingStub; 43 | 44 | private List filters = new ArrayList<>(); 45 | 46 | /** 47 | * 启动一个Remote Mitmproxy 48 | * @param mitmproxyHubAddr mitmproxy-hub服务的ip,不知道mitmproxy-hub是什么请看https://github.com/CreditTone/mitmproxy-hub 49 | * @param mitmproxyHubPort mitmproxy-hub服务的端口 50 | * @param remoteBind 在mitmproxy-hub这个机器上启动一个mitmproxy实例,告诉它需要绑定的IP。如果是本机的话绑定127.0.0.1即可,如果不是本机绑定0.0.0.0。并在使用的时候注意本机到mitmproxy-hub服务的IP关系。相信稍微有点网络知识不必我再说了吧 51 | * @param remoteBindPort 在mitmproxy-hub这个机器上启动一个mitmproxy实例,告诉它需要绑定的端口 52 | */ 53 | public RemoteMitmproxy(String mitmproxyHubAddr, int mitmproxyHubPort, String remoteBind, int remoteBindPort) { 54 | this(mitmproxyHubAddr, mitmproxyHubPort, remoteBind, remoteBindPort, null, null); 55 | } 56 | 57 | /** 58 | * 启动一个Remote Mitmproxy 59 | * @param mitmproxyHubAddr 60 | * @param mitmproxyHubPort 61 | * @param remoteBind 62 | * @param remoteBindPort 63 | * @param upstream 启动远端mitmproxy实例的同时设置一个上游的http代理 格式如:http://http-dyn.abuyun.com:9020、http://192.168.0.101:8080。类似命令:mitmdump --mode upstream:http://192.168.0.101:8080,还不了解自己去了解https://docs.mitmproxy.org/archive/v5/concepts-modes/#upstream-proxy 64 | */ 65 | public RemoteMitmproxy(String mitmproxyHubAddr, int mitmproxyHubPort, String remoteBind, int remoteBindPort, String upstream) { 66 | this(mitmproxyHubAddr, mitmproxyHubPort, remoteBind, remoteBindPort, upstream, null); 67 | } 68 | 69 | /** 70 | * 例如:RemoteMitmproxy remoteMitmproxy = new RemoteMitmproxy("127.0.0.1", 60051, "127.0.0.1", 8866, "http://http-dyn.abuyun.com:9020", "H889CWY00SVY012D:263445C168FAE095"); 71 | * 72 | * @param mitmproxyHubAddr 73 | * @param mitmproxyHubPort 74 | * @param remoteBind 75 | * @param remoteBindPort 76 | * @param upstream 启动远端mitmproxy实例的同时设置一个上游的http代理 格式如:http://http-dyn.abuyun.com:9020、http://192.168.0.101:8080 77 | * @param upstreamAuth 如果上游的http代理有验证,则设置。 格式:H889CWY00SVY012D:263445C168FAE095 78 | */ 79 | public RemoteMitmproxy(String mitmproxyHubAddr, int mitmproxyHubPort, String remoteBind, int remoteBindPort, String upstream, String upstreamAuth) { 80 | this.mitmproxyHubAddr = mitmproxyHubAddr; 81 | this.mitmproxyHubPort = mitmproxyHubPort; 82 | this.remoteBind = remoteBind; 83 | this.remoteBindPort = remoteBindPort; 84 | this.upstream = upstream; 85 | this.upstreamAuth = upstreamAuth; 86 | } 87 | 88 | public synchronized void start() { 89 | if (this.mitmproxyId == null) { 90 | MitmproxyFlowCallBackServer mitmproxyFlowCallBackServer = MitmproxyFlowCallBackServer.getInstance(); 91 | MitmproxyStartRequest.Builder builder = MitmproxyStartRequest.newBuilder() 92 | .setBind(remoteBind) 93 | .setPort(remoteBindPort) 94 | .setCallbackServerAddr("127.0.0.1") 95 | .setCallbackServerPort(mitmproxyFlowCallBackServer.port); 96 | if (this.upstream != null) { 97 | builder.setUpstream(upstream); 98 | } 99 | if (this.upstreamAuth != null) { 100 | builder.setUpstreamAuth(upstreamAuth); 101 | } 102 | Channel channel = ManagedChannelBuilder.forAddress(mitmproxyHubAddr, mitmproxyHubPort).usePlaintext().build(); 103 | this.mitmProxyHubServerBlockingStub = MitmProxyHubServerGrpc.newBlockingStub(channel); 104 | MitmproxyStartResponse response = mitmProxyHubServerBlockingStub.start(builder.build()); 105 | this.mitmproxyId = response.getMitmproxyId(); 106 | RemoteMitmproxies.put(mitmproxyId, this); 107 | } 108 | } 109 | 110 | 111 | public void addFlowFilter(FlowFilter flowFilter) { 112 | filters.add(flowFilter); 113 | } 114 | 115 | public boolean isRunning() { 116 | return mitmproxyId != null; 117 | } 118 | 119 | public void stop() { 120 | if (isRunning()) { 121 | try { 122 | MitmproxyStopRequest request = MitmproxyStopRequest.newBuilder().setMitmproxyId(mitmproxyId).build(); 123 | VoidResponse response = this.mitmProxyHubServerBlockingStub.stop(request); 124 | } catch (Exception e) { 125 | //e.printStackTrace(); 126 | } 127 | RemoteMitmproxies.remove(mitmproxyId); 128 | } 129 | } 130 | 131 | public void onRequest(FlowRequest flowRequest) { 132 | for (FlowFilter flowFilter : filters) { 133 | try { 134 | flowFilter.filterRequest(flowRequest); 135 | } catch (Exception e) { 136 | e.printStackTrace(); 137 | } 138 | } 139 | } 140 | 141 | public void onResponse(FlowResponse flowResponse) { 142 | for (FlowFilter flowFilter : filters) { 143 | try { 144 | flowFilter.filterResponse(flowResponse); 145 | } catch (Exception e) { 146 | e.printStackTrace(); 147 | } 148 | } 149 | } 150 | 151 | 152 | public String getRemoteBind() { 153 | return remoteBind; 154 | } 155 | 156 | public int getRemoteBindPort() { 157 | return remoteBindPort; 158 | } 159 | 160 | public static void main(String[] args) throws InterruptedException { 161 | RemoteMitmproxy remoteMitmproxy = new RemoteMitmproxy("127.0.0.1", 60051, "127.0.0.1", 8866, "http://http-dyn.abuyun.com:9020", "H889CWY00SVY012D:263445C168FAE095"); 162 | CookieCollectFilter cookieCollectFilter = new CookieCollectFilter(); 163 | remoteMitmproxy.addFlowFilter(cookieCollectFilter); 164 | remoteMitmproxy.addFlowFilter(new FlowFilter() { 165 | 166 | @Override 167 | public void filterResponse(FlowResponse flowResponse) { 168 | flowResponse.getHeaders().remove("Server"); 169 | } 170 | 171 | @Override 172 | public void filterRequest(FlowRequest flowRequest) { 173 | flowRequest.getHeaders().remove("User-Agent"); 174 | flowRequest.getHeaders().remove("Accept"); 175 | } 176 | }); 177 | remoteMitmproxy.start(); 178 | Thread.sleep(1000 * 30); 179 | remoteMitmproxy.stop(); 180 | for (Cookie cookie : cookieCollectFilter.catchCookies.values()) { 181 | System.out.println(cookie.getDomain() + ">>>"+ cookie.getName()+"="+cookie.getValue() +" path:"+cookie.getPath()); 182 | } 183 | } 184 | 185 | } 186 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/modle/FlowHeaders.java: -------------------------------------------------------------------------------- 1 | package com.deep007.mitmproxyjava.modle; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | 7 | import com.deep007.mitmproxyjava.MitmHeader; 8 | 9 | 10 | public class FlowHeaders extends HashMap { 11 | 12 | /** 13 | * 14 | */ 15 | private static final long serialVersionUID = 1L; 16 | 17 | public FlowHeaders(List headers) { 18 | for (MitmHeader header : headers) { 19 | put(header.getName(), header.getValue()); 20 | } 21 | } 22 | 23 | public List getMitmHeaders() { 24 | List headers = new ArrayList(); 25 | for (Entry header : entrySet()) { 26 | MitmHeader mitmHeader = MitmHeader.newBuilder() 27 | .setName(header.getKey()) 28 | .setValue(header.getValue()) 29 | .build(); 30 | headers.add(mitmHeader); 31 | } 32 | return headers; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/modle/FlowRequest.java: -------------------------------------------------------------------------------- 1 | package com.deep007.mitmproxyjava.modle; 2 | 3 | import java.nio.charset.Charset; 4 | import java.util.Map; 5 | 6 | import com.deep007.mitmproxyjava.MitmRequest; 7 | import com.google.protobuf.ByteString; 8 | 9 | public final class FlowRequest { 10 | 11 | public static final String CLASS_NAME = FlowRequest.class.getName(); 12 | 13 | 14 | public static FlowRequest create(MitmRequest request) { 15 | byte[] content = null; 16 | if (request.getContent() != null) { 17 | content = request.getContent().toByteArray(); 18 | } 19 | return new FlowRequest(request.getUrl(), request.getMethod(), new FlowHeaders(request.getHeadersList()), content); 20 | } 21 | 22 | public final MitmRequest getMitmRequest() { 23 | MitmRequest.Builder builder = MitmRequest.newBuilder() 24 | .setUrl(url) 25 | .setMethod(method) 26 | .addAllHeaders(headers.getMitmHeaders()); 27 | if (content != null) { 28 | builder.setContent(ByteString.copyFrom(content)); 29 | } 30 | return builder.build(); 31 | } 32 | 33 | private String url; 34 | private String method; 35 | private final FlowHeaders headers; 36 | private byte[] content; 37 | 38 | public FlowRequest(String url, String method, FlowHeaders headers, byte[] content) { 39 | this.url = url; 40 | this.method = method; 41 | this.headers = headers; 42 | this.content = content; 43 | } 44 | 45 | public String getUrl() { 46 | return url; 47 | } 48 | 49 | public void setUrl(String url) { 50 | this.url = url; 51 | } 52 | 53 | public String getMethod() { 54 | return method; 55 | } 56 | 57 | public void setMethod(String method) { 58 | this.method = method; 59 | } 60 | 61 | public byte[] getContent() { 62 | return content; 63 | } 64 | 65 | public String getContentAsString() { 66 | if (content == null) { 67 | return null; 68 | } 69 | return getContentAsString(Charset.forName("UTF-8")); 70 | } 71 | 72 | public String getContentAsString(Charset charset) { 73 | if (content == null) { 74 | return null; 75 | } 76 | return new String(content, charset); 77 | } 78 | 79 | public void setContent(byte[] content) { 80 | this.content = content; 81 | } 82 | 83 | public void setContentAsString(String content) { 84 | this.content = content.getBytes(Charset.forName("UTF-8")); 85 | } 86 | 87 | public void setContentAsString(String content, Charset charset) { 88 | this.content = content.getBytes(charset); 89 | } 90 | 91 | public Map getHeaders() { 92 | return headers; 93 | } 94 | 95 | public String getHeader(String name) { 96 | return headers.get(name); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/modle/FlowResponse.java: -------------------------------------------------------------------------------- 1 | package com.deep007.mitmproxyjava.modle; 2 | 3 | import java.nio.charset.Charset; 4 | import java.util.Map; 5 | 6 | import com.deep007.mitmproxyjava.MitmResponse; 7 | import com.google.protobuf.ByteString; 8 | 9 | public final class FlowResponse { 10 | 11 | public static final String CLASS_NAME = FlowResponse.class.getName(); 12 | 13 | public final static FlowResponse create(MitmResponse response) { 14 | FlowHeaders headers = new FlowHeaders(response.getHeadersList()); 15 | byte[] content = null; 16 | if (response.getContent() != null) { 17 | content = response.getContent().toByteArray(); 18 | } 19 | FlowRequest request = FlowRequest.create(response.getRequest()); 20 | return new FlowResponse(request, headers, content, response.getStatusCode()); 21 | } 22 | 23 | public final MitmResponse getMitmResponse() { 24 | MitmResponse.Builder builder = MitmResponse.newBuilder() 25 | .setStatusCode(statusCode) 26 | .addAllHeaders(headers.getMitmHeaders()) 27 | .setRequest(request.getMitmRequest()); 28 | if (content != null) { 29 | builder.setContent(ByteString.copyFrom(content)); 30 | } 31 | return builder.build(); 32 | } 33 | 34 | private final FlowRequest request; 35 | private final FlowHeaders headers; 36 | private byte[] content; 37 | private int statusCode; 38 | 39 | public FlowResponse(FlowRequest request, FlowHeaders headers, byte[] content, int statusCode) { 40 | super(); 41 | this.request = request; 42 | this.headers = headers; 43 | this.content = content; 44 | this.statusCode = statusCode; 45 | } 46 | 47 | public int getStatusCode() { 48 | return statusCode; 49 | } 50 | 51 | public void setStatusCode(int statusCode) { 52 | this.statusCode = statusCode; 53 | } 54 | 55 | public FlowRequest getRequest() { 56 | return request; 57 | } 58 | 59 | public byte[] getContent() { 60 | return content; 61 | } 62 | 63 | public String getContentAsString() { 64 | if (content == null) { 65 | return null; 66 | } 67 | return getContentAsString(Charset.forName("UTF-8")); 68 | } 69 | 70 | public String getContentAsString(Charset charset) { 71 | if (content == null) { 72 | return null; 73 | } 74 | return new String(content, charset); 75 | } 76 | 77 | public void setContent(byte[] content) { 78 | this.content = content; 79 | } 80 | 81 | public void setContentAsString(String content) { 82 | this.content = content.getBytes(Charset.forName("UTF-8")); 83 | } 84 | 85 | public void setContentAsString(String content, Charset charset) { 86 | this.content = content.getBytes(charset); 87 | } 88 | 89 | public Map getHeaders() { 90 | return headers; 91 | } 92 | 93 | public String getHeader(String name) { 94 | return headers.get(name); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/deep007/mitmproxyjava/modle/XUtils.java: -------------------------------------------------------------------------------- 1 | package com.deep007.mitmproxyjava.modle; 2 | 3 | public class XUtils { 4 | 5 | public static String getContentType(FlowResponse flowResponse) { 6 | if (flowResponse.getHeader("content-type") != null) { 7 | return flowResponse.getHeader("content-type"); 8 | } 9 | if (flowResponse.getHeader("Content-Type") != null) { 10 | return flowResponse.getHeader("Content-Type"); 11 | } 12 | return ""; 13 | } 14 | 15 | 16 | public static String getContentType(FlowRequest request) { 17 | if (request.getHeader("content-type") != null) { 18 | return request.getHeader("content-type"); 19 | } 20 | if (request.getHeader("Content-Type") != null) { 21 | return request.getHeader("Content-Type"); 22 | } 23 | return ""; 24 | } 25 | 26 | public static boolean isJavaScript(FlowResponse flowResponse) { 27 | String contentType = getContentType(flowResponse); 28 | if (contentType.contains("/javascript") || contentType.contains("/x-javascript")) { 29 | return true; 30 | } 31 | if (flowResponse.getRequest().getUrl().endsWith(".js")) { 32 | return true; 33 | } 34 | return false; 35 | } 36 | 37 | public static boolean isHtml(FlowResponse flowResponse) { 38 | String contentType = getContentType(flowResponse); 39 | if (contentType.contains("/html") || contentType.contains("/x-html")) { 40 | return true; 41 | } 42 | if (flowResponse.getRequest().getUrl().endsWith(".html") || flowResponse.getRequest().getUrl().endsWith(".htm")) { 43 | return true; 44 | } 45 | return false; 46 | } 47 | 48 | public static boolean isImage(FlowResponse flowResponse) { 49 | FlowRequest request = flowResponse.getRequest(); 50 | if (request.getHeader("Accept") != null && request.getHeader("Accept").startsWith("image/")) { 51 | return true; 52 | } 53 | String contentType = getContentType(flowResponse); 54 | if (contentType.contains("image/") || contentType.contains("image/")) { 55 | return true; 56 | } 57 | return false; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/io/grpc/internal/MessageDeframer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 The gRPC Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.grpc.internal; 18 | 19 | import static com.google.common.base.Preconditions.checkArgument; 20 | import static com.google.common.base.Preconditions.checkNotNull; 21 | import static com.google.common.base.Preconditions.checkState; 22 | 23 | import com.google.common.annotations.VisibleForTesting; 24 | import io.grpc.Codec; 25 | import io.grpc.Decompressor; 26 | import io.grpc.Status; 27 | import java.io.Closeable; 28 | import java.io.FilterInputStream; 29 | import java.io.IOException; 30 | import java.io.InputStream; 31 | import java.util.zip.DataFormatException; 32 | import javax.annotation.Nullable; 33 | import javax.annotation.concurrent.NotThreadSafe; 34 | 35 | /** 36 | * Deframer for GRPC frames. 37 | * 38 | *

This class is not thread-safe. Unless otherwise stated, all calls to public methods should be 39 | * made in the deframing thread. 40 | */ 41 | @NotThreadSafe 42 | public class MessageDeframer implements Closeable, Deframer { 43 | private static final int HEADER_LENGTH = 5; 44 | private static final int COMPRESSED_FLAG_MASK = 1; 45 | private static final int RESERVED_MASK = 0xFE; 46 | private static final int MAX_BUFFER_SIZE = 1024 * 1024 * 2; 47 | 48 | /** 49 | * A listener of deframing events. These methods will be invoked from the deframing thread. 50 | */ 51 | public interface Listener { 52 | 53 | /** 54 | * Called when the given number of bytes has been read from the input source of the deframer. 55 | * This is typically used to indicate to the underlying transport that more data can be 56 | * accepted. 57 | * 58 | * @param numBytes the number of bytes read from the deframer's input source. 59 | */ 60 | void bytesRead(int numBytes); 61 | 62 | /** 63 | * Called to deliver the next complete message. 64 | * 65 | * @param producer single message producer wrapping the message. 66 | */ 67 | void messagesAvailable(StreamListener.MessageProducer producer); 68 | 69 | /** 70 | * Called when the deframer closes. 71 | * 72 | * @param hasPartialMessage whether the deframer contained an incomplete message at closing. 73 | */ 74 | void deframerClosed(boolean hasPartialMessage); 75 | 76 | /** 77 | * Called when a {@link #deframe(ReadableBuffer)} operation failed. 78 | * 79 | * @param cause the actual failure 80 | */ 81 | void deframeFailed(Throwable cause); 82 | } 83 | 84 | private enum State { 85 | HEADER, BODY 86 | } 87 | 88 | private Listener listener; 89 | private int maxInboundMessageSize; 90 | private final StatsTraceContext statsTraceCtx; 91 | private final TransportTracer transportTracer; 92 | private Decompressor decompressor; 93 | private GzipInflatingBuffer fullStreamDecompressor; 94 | private byte[] inflatedBuffer; 95 | private int inflatedIndex; 96 | private State state = State.HEADER; 97 | private int requiredLength = HEADER_LENGTH; 98 | private boolean compressedFlag; 99 | private CompositeReadableBuffer nextFrame; 100 | private CompositeReadableBuffer unprocessed = new CompositeReadableBuffer(); 101 | private long pendingDeliveries; 102 | private boolean inDelivery = false; 103 | private int currentMessageSeqNo = -1; 104 | private int inboundBodyWireSize; 105 | 106 | private boolean closeWhenComplete = false; 107 | private volatile boolean stopDelivery = false; 108 | 109 | /** 110 | * Create a deframer. 111 | * 112 | * @param listener listener for deframer events. 113 | * @param decompressor the compression used if a compressed frame is encountered, with 114 | * {@code NONE} meaning unsupported 115 | * @param maxMessageSize the maximum allowed size for received messages. 116 | */ 117 | public MessageDeframer( 118 | Listener listener, 119 | Decompressor decompressor, 120 | int maxMessageSize, 121 | StatsTraceContext statsTraceCtx, 122 | TransportTracer transportTracer) { 123 | this.listener = checkNotNull(listener, "sink"); 124 | this.decompressor = checkNotNull(decompressor, "decompressor"); 125 | this.maxInboundMessageSize = maxMessageSize * 10; 126 | this.statsTraceCtx = checkNotNull(statsTraceCtx, "statsTraceCtx"); 127 | this.transportTracer = checkNotNull(transportTracer, "transportTracer"); 128 | } 129 | 130 | void setListener(Listener listener) { 131 | this.listener = listener; 132 | } 133 | 134 | @Override 135 | public void setMaxInboundMessageSize(int messageSize) { 136 | maxInboundMessageSize = messageSize; 137 | } 138 | 139 | @Override 140 | public void setDecompressor(Decompressor decompressor) { 141 | checkState(fullStreamDecompressor == null, "Already set full stream decompressor"); 142 | this.decompressor = checkNotNull(decompressor, "Can't pass an empty decompressor"); 143 | } 144 | 145 | @Override 146 | public void setFullStreamDecompressor(GzipInflatingBuffer fullStreamDecompressor) { 147 | checkState(decompressor == Codec.Identity.NONE, "per-message decompressor already set"); 148 | checkState(this.fullStreamDecompressor == null, "full stream decompressor already set"); 149 | this.fullStreamDecompressor = 150 | checkNotNull(fullStreamDecompressor, "Can't pass a null full stream decompressor"); 151 | unprocessed = null; 152 | } 153 | 154 | @Override 155 | public void request(int numMessages) { 156 | checkArgument(numMessages > 0, "numMessages must be > 0"); 157 | if (isClosed()) { 158 | return; 159 | } 160 | pendingDeliveries += numMessages; 161 | deliver(); 162 | } 163 | 164 | @Override 165 | public void deframe(ReadableBuffer data) { 166 | checkNotNull(data, "data"); 167 | boolean needToCloseData = true; 168 | try { 169 | if (!isClosedOrScheduledToClose()) { 170 | if (fullStreamDecompressor != null) { 171 | fullStreamDecompressor.addGzippedBytes(data); 172 | } else { 173 | unprocessed.addBuffer(data); 174 | } 175 | needToCloseData = false; 176 | 177 | deliver(); 178 | } 179 | } finally { 180 | if (needToCloseData) { 181 | data.close(); 182 | } 183 | } 184 | } 185 | 186 | @Override 187 | public void closeWhenComplete() { 188 | if (isClosed()) { 189 | return; 190 | } else if (isStalled()) { 191 | close(); 192 | } else { 193 | closeWhenComplete = true; 194 | } 195 | } 196 | 197 | /** 198 | * Sets a flag to interrupt delivery of any currently queued messages. This may be invoked outside 199 | * of the deframing thread, and must be followed by a call to {@link #close()} in the deframing 200 | * thread. Without a subsequent call to {@link #close()}, the deframer may hang waiting for 201 | * additional messages before noticing that the {@code stopDelivery} flag has been set. 202 | */ 203 | void stopDelivery() { 204 | stopDelivery = true; 205 | } 206 | 207 | @Override 208 | public void close() { 209 | if (isClosed()) { 210 | return; 211 | } 212 | boolean hasPartialMessage = nextFrame != null && nextFrame.readableBytes() > 0; 213 | try { 214 | if (fullStreamDecompressor != null) { 215 | hasPartialMessage = hasPartialMessage || fullStreamDecompressor.hasPartialData(); 216 | fullStreamDecompressor.close(); 217 | } 218 | if (unprocessed != null) { 219 | unprocessed.close(); 220 | } 221 | if (nextFrame != null) { 222 | nextFrame.close(); 223 | } 224 | } finally { 225 | fullStreamDecompressor = null; 226 | unprocessed = null; 227 | nextFrame = null; 228 | } 229 | listener.deframerClosed(hasPartialMessage); 230 | } 231 | 232 | /** 233 | * Indicates whether or not this deframer has been closed. 234 | */ 235 | public boolean isClosed() { 236 | return unprocessed == null && fullStreamDecompressor == null; 237 | } 238 | 239 | /** Returns true if this deframer has already been closed or scheduled to close. */ 240 | private boolean isClosedOrScheduledToClose() { 241 | return isClosed() || closeWhenComplete; 242 | } 243 | 244 | private boolean isStalled() { 245 | if (fullStreamDecompressor != null) { 246 | return fullStreamDecompressor.isStalled(); 247 | } else { 248 | return unprocessed.readableBytes() == 0; 249 | } 250 | } 251 | 252 | /** 253 | * Reads and delivers as many messages to the listener as possible. 254 | */ 255 | private void deliver() { 256 | // We can have reentrancy here when using a direct executor, triggered by calls to 257 | // request more messages. This is safe as we simply loop until pendingDelivers = 0 258 | if (inDelivery) { 259 | return; 260 | } 261 | inDelivery = true; 262 | try { 263 | // Process the uncompressed bytes. 264 | while (!stopDelivery && pendingDeliveries > 0 && readRequiredBytes()) { 265 | switch (state) { 266 | case HEADER: 267 | processHeader(); 268 | break; 269 | case BODY: 270 | // Read the body and deliver the message. 271 | processBody(); 272 | 273 | // Since we've delivered a message, decrement the number of pending 274 | // deliveries remaining. 275 | pendingDeliveries--; 276 | break; 277 | default: 278 | throw new AssertionError("Invalid state: " + state); 279 | } 280 | } 281 | 282 | if (stopDelivery) { 283 | close(); 284 | return; 285 | } 286 | 287 | /* 288 | * We are stalled when there are no more bytes to process. This allows delivering errors as 289 | * soon as the buffered input has been consumed, independent of whether the application 290 | * has requested another message. At this point in the function, either all frames have been 291 | * delivered, or unprocessed is empty. If there is a partial message, it will be inside next 292 | * frame and not in unprocessed. If there is extra data but no pending deliveries, it will 293 | * be in unprocessed. 294 | */ 295 | if (closeWhenComplete && isStalled()) { 296 | close(); 297 | } 298 | } finally { 299 | inDelivery = false; 300 | } 301 | } 302 | 303 | /** 304 | * Attempts to read the required bytes into nextFrame. 305 | * 306 | * @return {@code true} if all of the required bytes have been read. 307 | */ 308 | private boolean readRequiredBytes() { 309 | int totalBytesRead = 0; 310 | int deflatedBytesRead = 0; 311 | try { 312 | if (nextFrame == null) { 313 | nextFrame = new CompositeReadableBuffer(); 314 | } 315 | 316 | // Read until the buffer contains all the required bytes. 317 | int missingBytes; 318 | while ((missingBytes = requiredLength - nextFrame.readableBytes()) > 0) { 319 | if (fullStreamDecompressor != null) { 320 | try { 321 | if (inflatedBuffer == null || inflatedIndex == inflatedBuffer.length) { 322 | inflatedBuffer = new byte[Math.min(missingBytes, MAX_BUFFER_SIZE)]; 323 | inflatedIndex = 0; 324 | } 325 | int bytesToRead = Math.min(missingBytes, inflatedBuffer.length - inflatedIndex); 326 | int n = fullStreamDecompressor.inflateBytes(inflatedBuffer, inflatedIndex, bytesToRead); 327 | totalBytesRead += fullStreamDecompressor.getAndResetBytesConsumed(); 328 | deflatedBytesRead += fullStreamDecompressor.getAndResetDeflatedBytesConsumed(); 329 | if (n == 0) { 330 | // No more inflated data is available. 331 | return false; 332 | } 333 | nextFrame.addBuffer(ReadableBuffers.wrap(inflatedBuffer, inflatedIndex, n)); 334 | inflatedIndex += n; 335 | } catch (IOException e) { 336 | throw new RuntimeException(e); 337 | } catch (DataFormatException e) { 338 | throw new RuntimeException(e); 339 | } 340 | } else { 341 | if (unprocessed.readableBytes() == 0) { 342 | // No more data is available. 343 | return false; 344 | } 345 | int toRead = Math.min(missingBytes, unprocessed.readableBytes()); 346 | totalBytesRead += toRead; 347 | nextFrame.addBuffer(unprocessed.readBytes(toRead)); 348 | } 349 | } 350 | return true; 351 | } finally { 352 | if (totalBytesRead > 0) { 353 | listener.bytesRead(totalBytesRead); 354 | if (state == State.BODY) { 355 | if (fullStreamDecompressor != null) { 356 | // With compressed streams, totalBytesRead can include gzip header and trailer metadata 357 | statsTraceCtx.inboundWireSize(deflatedBytesRead); 358 | inboundBodyWireSize += deflatedBytesRead; 359 | } else { 360 | statsTraceCtx.inboundWireSize(totalBytesRead); 361 | inboundBodyWireSize += totalBytesRead; 362 | } 363 | } 364 | } 365 | } 366 | } 367 | 368 | /** 369 | * Processes the GRPC compression header which is composed of the compression flag and the outer 370 | * frame length. 371 | */ 372 | private void processHeader() { 373 | int type = nextFrame.readUnsignedByte(); 374 | if ((type & RESERVED_MASK) != 0) { 375 | throw Status.INTERNAL.withDescription( 376 | "gRPC frame header malformed: reserved bits not zero") 377 | .asRuntimeException(); 378 | } 379 | compressedFlag = (type & COMPRESSED_FLAG_MASK) != 0; 380 | 381 | // Update the required length to include the length of the frame. 382 | requiredLength = nextFrame.readInt(); 383 | if (requiredLength < 0 || requiredLength > maxInboundMessageSize) { 384 | throw Status.RESOURCE_EXHAUSTED.withDescription( 385 | String.format("gRPC message exceeds maximum size %d: %d", 386 | maxInboundMessageSize, requiredLength)) 387 | .asRuntimeException(); 388 | } 389 | 390 | currentMessageSeqNo++; 391 | statsTraceCtx.inboundMessage(currentMessageSeqNo); 392 | transportTracer.reportMessageReceived(); 393 | // Continue reading the frame body. 394 | state = State.BODY; 395 | } 396 | 397 | /** 398 | * Processes the GRPC message body, which depending on frame header flags may be compressed. 399 | */ 400 | private void processBody() { 401 | // There is no reliable way to get the uncompressed size per message when it's compressed, 402 | // because the uncompressed bytes are provided through an InputStream whose total size is 403 | // unknown until all bytes are read, and we don't know when it happens. 404 | statsTraceCtx.inboundMessageRead(currentMessageSeqNo, inboundBodyWireSize, -1); 405 | inboundBodyWireSize = 0; 406 | InputStream stream = compressedFlag ? getCompressedBody() : getUncompressedBody(); 407 | nextFrame = null; 408 | listener.messagesAvailable(new SingleMessageProducer(stream)); 409 | 410 | // Done with this frame, begin processing the next header. 411 | state = State.HEADER; 412 | requiredLength = HEADER_LENGTH; 413 | } 414 | 415 | private InputStream getUncompressedBody() { 416 | statsTraceCtx.inboundUncompressedSize(nextFrame.readableBytes()); 417 | return ReadableBuffers.openStream(nextFrame, true); 418 | } 419 | 420 | private InputStream getCompressedBody() { 421 | if (decompressor == Codec.Identity.NONE) { 422 | throw Status.INTERNAL.withDescription( 423 | "Can't decode compressed gRPC message as compression not configured") 424 | .asRuntimeException(); 425 | } 426 | 427 | try { 428 | // Enforce the maxMessageSize limit on the returned stream. 429 | InputStream unlimitedStream = 430 | decompressor.decompress(ReadableBuffers.openStream(nextFrame, true)); 431 | return new SizeEnforcingInputStream( 432 | unlimitedStream, maxInboundMessageSize, statsTraceCtx); 433 | } catch (IOException e) { 434 | throw new RuntimeException(e); 435 | } 436 | } 437 | 438 | /** 439 | * An {@link InputStream} that enforces the {@link #maxMessageSize} limit for compressed frames. 440 | */ 441 | @VisibleForTesting 442 | static final class SizeEnforcingInputStream extends FilterInputStream { 443 | private final int maxMessageSize; 444 | private final StatsTraceContext statsTraceCtx; 445 | private long maxCount; 446 | private long count; 447 | private long mark = -1; 448 | 449 | SizeEnforcingInputStream(InputStream in, int maxMessageSize, StatsTraceContext statsTraceCtx) { 450 | super(in); 451 | this.maxMessageSize = maxMessageSize; 452 | this.statsTraceCtx = statsTraceCtx; 453 | } 454 | 455 | @Override 456 | public int read() throws IOException { 457 | int result = in.read(); 458 | if (result != -1) { 459 | count++; 460 | } 461 | verifySize(); 462 | reportCount(); 463 | return result; 464 | } 465 | 466 | @Override 467 | public int read(byte[] b, int off, int len) throws IOException { 468 | int result = in.read(b, off, len); 469 | if (result != -1) { 470 | count += result; 471 | } 472 | verifySize(); 473 | reportCount(); 474 | return result; 475 | } 476 | 477 | @Override 478 | public long skip(long n) throws IOException { 479 | long result = in.skip(n); 480 | count += result; 481 | verifySize(); 482 | reportCount(); 483 | return result; 484 | } 485 | 486 | @Override 487 | public synchronized void mark(int readlimit) { 488 | in.mark(readlimit); 489 | mark = count; 490 | // it's okay to mark even if mark isn't supported, as reset won't work 491 | } 492 | 493 | @Override 494 | public synchronized void reset() throws IOException { 495 | if (!in.markSupported()) { 496 | throw new IOException("Mark not supported"); 497 | } 498 | if (mark == -1) { 499 | throw new IOException("Mark not set"); 500 | } 501 | 502 | in.reset(); 503 | count = mark; 504 | } 505 | 506 | private void reportCount() { 507 | if (count > maxCount) { 508 | statsTraceCtx.inboundUncompressedSize(count - maxCount); 509 | maxCount = count; 510 | } 511 | } 512 | 513 | private void verifySize() { 514 | if (count > maxMessageSize) { 515 | throw Status.RESOURCE_EXHAUSTED.withDescription(String.format( 516 | "Compressed gRPC message exceeds maximum size %d: %d bytes read", 517 | maxMessageSize, count)).asRuntimeException(); 518 | } 519 | } 520 | } 521 | 522 | private static class SingleMessageProducer implements StreamListener.MessageProducer { 523 | private InputStream message; 524 | 525 | private SingleMessageProducer(InputStream message) { 526 | this.message = message; 527 | } 528 | 529 | @Nullable 530 | @Override 531 | public InputStream next() { 532 | InputStream messageToReturn = message; 533 | message = null; 534 | return messageToReturn; 535 | } 536 | } 537 | } 538 | -------------------------------------------------------------------------------- /src/main/resources/mitm_hub_client.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | //把proto文件拷贝到resources根目录,然后项目下执行mvn clean compile生成grpc java代码 4 | option java_package = "com.deep007.mitmproxyjava"; 5 | option java_outer_classname = "MitmProxyHubClientServerProto"; 6 | option java_multiple_files = true; 7 | 8 | package mitm; 9 | 10 | 11 | //MitmProxyHubServer负责启动mitmproxy和通知回调client端 12 | service MitmProxyHubServer { 13 | rpc start(MitmproxyStartRequest) returns (MitmproxyStartResponse) {} 14 | rpc stop(MitmproxyStopRequest) returns (VoidResponse) {} 15 | } 16 | 17 | //java、go、c++客户端回调server实现,它接收mitmproxy流量的回调,修改并返回给python端 18 | service MitmProxyHubClientServer { 19 | rpc onMitmRequest(MitmRequest) returns (MitmRequest) {} 20 | rpc onMitmResponse(MitmResponse) returns (MitmResponse) {} 21 | } 22 | 23 | message VoidResponse {} 24 | 25 | message MitmproxyStartRequest { 26 | string bind = 1; 27 | int32 port = 2; 28 | string callbackServerAddr = 3; 29 | int32 callbackServerPort = 4; 30 | string upstream = 5; 31 | string upstreamAuth = 6; 32 | } 33 | 34 | message MitmproxyStartResponse { 35 | string mitmproxyId = 1; 36 | } 37 | 38 | message MitmproxyStopRequest { 39 | string mitmproxyId = 1; 40 | } 41 | 42 | message MitmHeader { 43 | string name = 1; 44 | string value = 2; 45 | } 46 | 47 | message MitmRequest { 48 | string url = 1; 49 | string method = 2; 50 | repeated MitmHeader headers = 3; 51 | bytes content = 4; 52 | string mitmproxyId = 5; 53 | } 54 | 55 | message MitmResponse { 56 | MitmRequest request = 1; 57 | repeated MitmHeader headers = 2; 58 | bytes content = 3; 59 | int32 statusCode = 4; 60 | string mitmproxyId = 5; 61 | } --------------------------------------------------------------------------------