Skip to content

Commit e435a9b

Browse files
committed
add some code
1 parent 0e6dd08 commit e435a9b

12 files changed

+220
-0
lines changed

Diff for: .config/dotnet-tools.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"csharpier": {
6+
"version": "0.18.0",
7+
"commands": ["dotnet-csharpier"]
8+
}
9+
}
10+
}

Diff for: .editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[*.{yml,yaml}]
16+
indent_size = 2

Diff for: .github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: eai04191

Diff for: .github/workflows/build.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Setup .NET
14+
uses: actions/setup-dotnet@v2
15+
with:
16+
dotnet-version: 6.0.x
17+
18+
- name: Restore dependencies
19+
run: dotnet restore
20+
21+
- name: Build
22+
run: dotnet build --no-restore
23+
24+
- name: Upload artifact
25+
uses: actions/upload-artifact@v3
26+
with:
27+
path: ${{ github.workspace }}/bin/Debug/netstandard2.1/net.laoplus.HttpProxy.dll
28+
if-no-files-found: error

Diff for: .github/workflows/format.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Check code format
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
prettier:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Check code format with prettier
14+
run: |
15+
npx -y prettier . --check --ignore-path .gitignore
16+
17+
csharpier:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: Check code format with csharpier
24+
run: |
25+
dotnet tool restore
26+
dotnet dotnet-csharpier --check .

Diff for: .gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
# Created by https://www.toptal.com/developers/gitignore/api/dotnetcore
3+
# Edit at https://www.toptal.com/developers/gitignore?templates=dotnetcore
4+
5+
### DotnetCore ###
6+
# .NET Core build folders
7+
bin/
8+
obj/
9+
10+
# Common node modules locations
11+
/node_modules
12+
/wwwroot/node_modules
13+
14+
# End of https://www.toptal.com/developers/gitignore/api/dotnetcore
15+
16+
.vs
17+
.idea

Diff for: HttpProxy.csproj

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.1</TargetFramework>
5+
<AssemblyName>net.laoplus.HttpProxy</AssemblyName>
6+
<Product>HttpProxy</Product>
7+
<Description>Set global proxy for BestHTTP</Description>
8+
<Version>1.0.0</Version>
9+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
10+
<LangVersion>latest</LangVersion>
11+
<DebugType>none</DebugType>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<PackageReference Include="BepInEx.IL2CPP" Version="6.0.0-*" IncludeAssets="compile" />
16+
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
17+
<PackageReference Include="LastOrigin.GameLibs" Version="*-*" />
18+
</ItemGroup>
19+
</Project>

Diff for: HttpProxy.sln

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpProxy", "HttpProxy.csproj", "{5D646289-5FB3-4263-9C0F-2889042C383D}"
4+
EndProject
5+
Global
6+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7+
Debug|Any CPU = Debug|Any CPU
8+
Release|Any CPU = Release|Any CPU
9+
EndGlobalSection
10+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
11+
{5D646289-5FB3-4263-9C0F-2889042C383D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
12+
{5D646289-5FB3-4263-9C0F-2889042C383D}.Debug|Any CPU.Build.0 = Debug|Any CPU
13+
{5D646289-5FB3-4263-9C0F-2889042C383D}.Release|Any CPU.ActiveCfg = Release|Any CPU
14+
{5D646289-5FB3-4263-9C0F-2889042C383D}.Release|Any CPU.Build.0 = Release|Any CPU
15+
EndGlobalSection
16+
EndGlobal

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Eai
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: NuGet.Config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
5+
</packageSources>
6+
</configuration>

Diff for: Plugin.cs

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using BepInEx;
2+
using BepInEx.Configuration;
3+
using BepInEx.IL2CPP;
4+
using BepInEx.Logging;
5+
using BestHTTP;
6+
using Il2CppSystem;
7+
using EventArgs = System.EventArgs;
8+
9+
namespace HttpProxy
10+
{
11+
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
12+
public class Plugin : BasePlugin
13+
{
14+
static ManualLogSource _log;
15+
static ConfigEntry<string> _configHttpProxyURL;
16+
17+
public override void Load()
18+
{
19+
_log = Log;
20+
_log.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
21+
22+
_configHttpProxyURL = Config.Bind(
23+
"Proxy",
24+
"HTTP Proxy URL",
25+
"http://localhost:8888",
26+
"A HTTP Proxy URL. If empty, no proxy will be used."
27+
);
28+
_configHttpProxyURL.SettingChanged += OnConfigChanged;
29+
InitProxy();
30+
}
31+
32+
static void InitProxy()
33+
{
34+
if (string.IsNullOrEmpty(_configHttpProxyURL.Value))
35+
{
36+
_log.LogInfo("No proxy will be used.");
37+
HTTPManager.Proxy = null;
38+
return;
39+
}
40+
41+
_log.LogInfo($"Using proxy {_configHttpProxyURL.Value}.");
42+
HTTPManager.Proxy = new HTTPProxy(new Uri(_configHttpProxyURL.Value));
43+
}
44+
45+
static void OnConfigChanged(object sender, EventArgs e)
46+
{
47+
if (e is not SettingChangedEventArgs)
48+
{
49+
return;
50+
}
51+
52+
InitProxy();
53+
}
54+
}
55+
}

Diff for: README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# HttpProxy
2+
3+
Set any HTTP proxy, such as Charles or Fiddler, as the BestHTTP global proxy. It depends on LastOrigin's GameLibs, but it doesn't use any game code, so it should work for all games that use BestHTTP.
4+
5+
- [BestHTTP Documentation](https://benedicht.github.io/BestHTTP-Documentation/pages/best_http2/global_topics/GlobalSettings.html)

0 commit comments

Comments
 (0)