Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/main/java/core/packetproxy/common/ConfigDaoHub.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2026 DeNA Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package packetproxy.common;

import com.google.gson.annotations.SerializedName;
import java.util.List;
import packetproxy.model.*;

/** 設定エクスポート/インポート用 JSON の DTO。 */
public class ConfigDaoHub {

@SerializedName(value = "listenPorts")
List<ListenPort> listenPortList;

@SerializedName(value = "servers")
List<Server> serverList;

@SerializedName(value = "modifications")
List<Modification> modificationList;

@SerializedName(value = "sslPassThroughs")
List<SSLPassThrough> sslPassThroughList;
}
22 changes: 3 additions & 19 deletions src/main/java/core/packetproxy/common/ConfigHttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
import fi.iki.elonen.NanoHTTPD;
import java.util.HashMap;
import java.util.List;
Expand All @@ -15,21 +14,6 @@ public class ConfigHttpServer extends NanoHTTPD {

private final String allowedAccessToken;

private static class DaoHub {

@SerializedName(value = "listenPorts")
List<ListenPort> listenPortList;

@SerializedName(value = "servers")
List<Server> serverList;

@SerializedName(value = "modifications")
List<Modification> modificationList;

@SerializedName(value = "sslPassThroughs")
List<SSLPassThrough> sslPassThroughList;
}

public ConfigHttpServer(String hostname, int port, String allowedAccessToken) {
super(hostname, port);
this.allowedAccessToken = allowedAccessToken;
Expand Down Expand Up @@ -74,7 +58,7 @@ private void fixUpModificationList(Map<Integer, Integer> serverMap, List<Modific
}
}

private void fixUp(DaoHub daoHub) {
private void fixUp(ConfigDaoHub daoHub) {
Map<Integer, Integer> serverMap = new HashMap<>();
fixUpServerList(serverMap, daoHub.serverList);
fixUpListenPortList(serverMap, daoHub.listenPortList);
Expand Down Expand Up @@ -107,7 +91,7 @@ public Response serve(IHTTPSession session) {

try {

DaoHub daoHub = new DaoHub();
ConfigDaoHub daoHub = new ConfigDaoHub();

daoHub.listenPortList = ListenPorts.getInstance().queryAll();
daoHub.serverList = Servers.getInstance().queryAll();
Expand Down Expand Up @@ -153,7 +137,7 @@ public Response serve(IHTTPSession session) {
session.parseBody(map);
String json = map.get("postData");

DaoHub daoHub = new Gson().fromJson(json, DaoHub.class);
ConfigDaoHub daoHub = new Gson().fromJson(json, ConfigDaoHub.class);

Database.getInstance().dropConfigs();

Expand Down
22 changes: 3 additions & 19 deletions src/main/java/core/packetproxy/common/ConfigIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -11,21 +10,6 @@

public class ConfigIO {

private static class DaoHub {

@SerializedName(value = "listenPorts")
List<ListenPort> listenPortList;

@SerializedName(value = "servers")
List<Server> serverList;

@SerializedName(value = "modifications")
List<Modification> modificationList;

@SerializedName(value = "sslPassThroughs")
List<SSLPassThrough> sslPassThroughList;
}

public ConfigIO() {
}

Expand Down Expand Up @@ -68,15 +52,15 @@ private void fixUpModificationList(Map<Integer, Integer> serverMap, List<Modific
}
}

private void fixUp(DaoHub daoHub) {
private void fixUp(ConfigDaoHub daoHub) {
Map<Integer, Integer> serverMap = new HashMap<>();
fixUpServerList(serverMap, daoHub.serverList);
fixUpListenPortList(serverMap, daoHub.listenPortList);
fixUpModificationList(serverMap, daoHub.modificationList);
}

public String getOptions() throws Exception {
DaoHub daoHub = new DaoHub();
ConfigDaoHub daoHub = new ConfigDaoHub();

daoHub.listenPortList = ListenPorts.getInstance().queryAll();
daoHub.serverList = Servers.getInstance().queryAll();
Expand All @@ -92,7 +76,7 @@ public String getOptions() throws Exception {
}

public void setOptions(String json) throws Exception {
DaoHub daoHub = new Gson().fromJson(json, DaoHub.class);
ConfigDaoHub daoHub = new Gson().fromJson(json, ConfigDaoHub.class);

Database.getInstance().dropConfigs();

Expand Down
Loading