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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/***/*.sqlite3
/***/*.class
/***/.DS_Store
/.kotlin

# jenv
.java-version
Expand Down
32 changes: 22 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import com.bmuschko.gradle.izpack.CreateInstallerTask
import org.apache.tools.ant.taskdefs.condition.Os
import com.bmuschko.gradle.izpack.*
import org.gradle.plugins.ide.eclipse.model.AccessRule

buildscript {
Expand All @@ -17,15 +17,15 @@ plugins {
id 'com.github.jk1.dependency-license-report' version '2.5'
id "de.undercouch.download" version "5.6.0"
id "com.diffplug.spotless" version "7.1.0"
id 'org.jetbrains.kotlin.jvm' version '2.2.21'
}

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url = 'https://jitpack.io' }
}

dependencies {

compileOnly 'org.projectlombok:lombok:1.18.42'
annotationProcessor 'org.projectlombok:lombok:1.18.42'
testCompileOnly 'org.projectlombok:lombok:1.18.42'
Expand All @@ -46,8 +46,11 @@ dependencies {
implementation 'com.j256.ormlite:ormlite-core:4.48'
implementation 'com.j256.ormlite:ormlite-jdbc:4.48'
implementation 'com.google.protobuf:protobuf-java:4.31.1'
implementation 'org.slf4j:slf4j-api:1.7.14'
implementation 'org.slf4j:slf4j-api:2.0.9'
implementation 'org.slf4j:slf4j-log4j12:1.7.25'
implementation 'org.jline:jline:3.25.1'
implementation 'org.jline:jline-terminal-jansi:3.25.1'
implementation 'ch.qos.logback:logback-classic:1.4.14'
implementation 'com.googlecode.java-diff-utils:diffutils:1.2.1'
implementation 'com.google.re2j:re2j:1.1'
implementation 'com.github.mobius-software-ltd:mqtt-parser:parser-1.0.3'
Expand All @@ -72,6 +75,7 @@ dependencies {
implementation 'com.github.luben:zstd-jni:1.5.6-3'
implementation 'org.brotli:dec:0.1.2'
implementation files('libs/agent15.jar')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"

izpack 'org.codehaus.izpack:izpack-dist:5.1.3'

Expand Down Expand Up @@ -116,6 +120,14 @@ spotless {
formatAnnotations()
}

kotlin {
target '**/*.kt'

ktfmt().googleStyle()
trimTrailingWhitespace()
endWithNewline()
}

groovy {
target '**/*.gradle'

Expand All @@ -133,14 +145,14 @@ spotless {
}

application {
mainClass = "packetproxy/PacketProxy"
mainClass = "packetproxy.PacketProxy"
}

def shell(String command) {
["sh", "-c", command].execute().waitForProcessOutput(System.out, System.err)
}

def gitVersion = "git describe --tags --abbrev=0".execute().text.replace("\n","")
def gitVersion = "git describe --tags --abbrev=0".execute().text.replace("\n", "")
new File("${projectDir}/src/main/resources/version").text = gitVersion

project.ext {
Expand Down Expand Up @@ -265,13 +277,13 @@ jar {
serviceDir.deleteDir()
serviceDir.mkdirs()
for (file in configurations.runtimeClasspath) {
zipTree(file).matching{ include 'META-INF/services/*' }.each { f ->
zipTree(file).matching { include 'META-INF/services/*' }.each { f ->
new File(serviceDir, f.name) << f.getText("UTF-8") << "\n"
}
}
}
manifest {
attributes (
attributes(
"Main-Class": "packetproxy/PacketProxy",
"Class-Path": configurations.runtimeClasspath.collect { it.getName() }.join(' ')
)
Expand Down Expand Up @@ -433,7 +445,7 @@ task preIzpack {
}
}

task izpackWin64 (type: CreateInstallerTask, dependsOn: [
task izpackWin64(type: CreateInstallerTask, dependsOn: [
'createWin64Target',
'preIzpack'
]) {
Expand All @@ -446,7 +458,7 @@ task izpackWin64 (type: CreateInstallerTask, dependsOn: [
'app.version': gitVersion, 'app.subpath': "PacketProxy-${gitVersion}"]
}

task izpackLinux (type: CreateInstallerTask, dependsOn: [
task izpackLinux(type: CreateInstallerTask, dependsOn: [
'createLinuxTarget',
'preIzpack'
]) {
Expand Down
8 changes: 8 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
pluginManagement {
plugins {
id 'org.jetbrains.kotlin.jvm' version '2.2.0'
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}
rootProject.name = "PacketProxy"
80 changes: 0 additions & 80 deletions src/main/java/core/packetproxy/ProxyFactory.java
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このファイルは復活させてもらえると

This file was deleted.

54 changes: 0 additions & 54 deletions src/main/java/core/packetproxy/util/Logging.java
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このファイルも復活させてください

This file was deleted.

59 changes: 59 additions & 0 deletions src/main/kotlin/core/packetproxy/ProxyFactory.kt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このファイルですが、現在PacketProxyを利用している人が、kotlinの環境を整えないとコンパイルできなくなってしまうので、もとのJavaファイルに戻してもらえると助かります。
PacketProxy本体をJavaからkotlinに変更するときは、一斉に全てのファイルをkotlinに変更した上でメジャーバージョンを1つ繰り上げ、さらに周知をしたいと思います。

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2025 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

import java.net.ServerSocket
import packetproxy.common.I18nString
import packetproxy.model.ListenPort
import packetproxy.util.Logging

object ProxyFactory {
@JvmStatic
@Throws(Exception::class)
fun create(listenInfo: ListenPort): Proxy {
val type = listenInfo.getType()
val port = listenInfo.getPort()

Logging.log("type is $type")
Logging.log(I18nString.get("Start listening port %d.", port))

return when (type) {
ListenPort.TYPE.UDP_FORWARDER -> ProxyUDPForward(listenInfo)
ListenPort.TYPE.QUIC_FORWARDER -> ProxyQuicForward(listenInfo)
ListenPort.TYPE.QUIC_TRANSPARENT_PROXY -> ProxyQuicTransparent(listenInfo)

else -> {
val listenSocket = ServerSocket(port)

when (type) {
ListenPort.TYPE.HTTP_PROXY -> ProxyHttp(listenSocket, listenInfo)
ListenPort.TYPE.SSL_FORWARDER -> ProxySSLForward(listenSocket, listenInfo)
ListenPort.TYPE.HTTP_TRANSPARENT_PROXY -> ProxyHttpTransparent(listenSocket, listenInfo)
ListenPort.TYPE.SSL_TRANSPARENT_PROXY -> ProxySSLTransparent(listenSocket, listenInfo)

else -> {
listenSocket.setReuseAddress(true)

when (type) {
ListenPort.TYPE.XMPP_SSL_FORWARDER -> ProxyXmppSSLForward(listenSocket, listenInfo)
else -> ProxyForward(listenSocket, listenInfo)
}
}
}
}
}
}
}
Loading