Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e3bcf6
commit df24c6a
Showing
19 changed files
with
121 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
common/src/main/java/com/soulfiremc/util/ReactorHttpHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* SoulFire | ||
* Copyright (C) 2024 AlexProgrammerDE | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.soulfiremc.util; | ||
|
||
import com.soulfiremc.builddata.BuildData; | ||
import com.soulfiremc.proxy.SFProxy; | ||
import java.time.Duration; | ||
import reactor.netty.transport.ProxyProvider; | ||
|
||
public class ReactorHttpHelper { | ||
private ReactorHttpHelper() {} | ||
|
||
public static reactor.netty.http.client.HttpClient createReactorClient( | ||
SFProxy proxyData, boolean withBody) { | ||
var base = | ||
reactor.netty.http.client.HttpClient.create() | ||
.responseTimeout(Duration.ofSeconds(5)) | ||
.headers( | ||
h -> { | ||
h.add("Accept", "application/json"); | ||
if (withBody) { | ||
h.add("Content-Type", "application/json"); | ||
} | ||
|
||
h.add("Accept-Language", "en-US,en"); | ||
h.add("User-Agent", "SoulFire/" + BuildData.VERSION); | ||
}); | ||
|
||
return proxyData == null | ||
? base | ||
: base.proxy( | ||
p -> { | ||
var spec = | ||
p.type( | ||
switch (proxyData.type()) { | ||
case HTTP -> ProxyProvider.Proxy.HTTP; | ||
case SOCKS4 -> ProxyProvider.Proxy.SOCKS4; | ||
case SOCKS5 -> ProxyProvider.Proxy.SOCKS5; | ||
}) | ||
.host(proxyData.host()) | ||
.port(proxyData.port()) | ||
.nonProxyHosts("localhost") | ||
.connectTimeoutMillis(20_000); | ||
|
||
if (proxyData.username() != null) { | ||
spec.username(proxyData.username()); | ||
} | ||
|
||
if (proxyData.password() != null) { | ||
spec.password(s -> proxyData.password()); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
j8-launcher/src/main/java/com/soulfiremc/launcher/SoulFireClientLauncher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.soulfiremc.launcher; | ||
|
||
public class SoulFireClientLauncher { | ||
public static void main(String[] args) { | ||
SoulFireJava8LauncherWrapper.mainWrapper(args, "com.soulfiremc.SoulFireLauncher"); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
j8-launcher/src/main/java/com/soulfiremc/launcher/SoulFireDedicatedServerLauncher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.soulfiremc.launcher; | ||
|
||
public class SoulFireDedicatedServerLauncher { | ||
public static void main(String[] args) { | ||
SoulFireJava8LauncherWrapper.mainWrapper(args, "com.soulfiremc.SoulFireLauncher"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.