Skip to content

Commit

Permalink
add MaxDatagramChannelCount to User Setting
Browse files Browse the repository at this point in the history
make android TV compatible
Sync all active session to access server every few minutes
  • Loading branch information
trudyhood committed Mar 17, 2022
1 parent 4d685b2 commit db3cc82
Show file tree
Hide file tree
Showing 44 changed files with 813 additions and 504 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Upcoming
### Server
* Update: Sync all active session to access server every few minutes
* Fix: Maintenance mode detection
* Fix: Synching sessions to access server on shut down

# v2.4.295
### Client
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"WSL": {
"commandName": "WSL2",
"distributionName": ""
}
}
}
2 changes: 1 addition & 1 deletion VpnHood.Client.App.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
namespace VpnHood.Client.App.Android
{
[Activity(Label = "@string/app_name",
Icon = "@mipmap/ic_launcher",
Theme = "@android:style/Theme.DeviceDefault.NoActionBar",
MainLauncher = true, AlwaysRetainTaskState = true, LaunchMode = LaunchMode.SingleInstance,
ScreenOrientation = ScreenOrientation.UserPortrait,
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.LayoutDirection |
ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.FontScale |
ConfigChanges.Locale | ConfigChanges.Navigation | ConfigChanges.UiMode)]
[IntentFilter(new[] { "android.intent.action.MAIN" }, Categories = new[] { "android.intent.category.LEANBACK_LAUNCHER" })]
public class MainActivity : Activity
{
private const int RequestVpnPermission = 10;
Expand Down
7 changes: 5 additions & 2 deletions VpnHood.Client.App.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="295" package="com.vpnhood.client.android" android:installLocation="auto" android:versionName="2.4.295">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="295" package="com.vpnhood.client.android"
android:installLocation="auto" android:versionName="2.4.295" >
<uses-sdk android:minSdkVersion="22" android:targetSdkVersion="31" />
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher">
<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:banner="@mipmap/banner">
</application>
<queries>
<intent>
Expand Down
13 changes: 8 additions & 5 deletions VpnHood.Client.App.Android/Resources/Resource.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 45 additions & 20 deletions VpnHood.Client.App.Android/VpnHood.Client.App.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,6 @@
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher_foreground.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher_round.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xxhdpi\ic_launcher.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
Expand Down Expand Up @@ -232,11 +217,6 @@
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xhdpi\ic_notification.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xxhdpi\ic_notification.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
Expand Down Expand Up @@ -268,5 +248,50 @@
<ItemGroup>
<AndroidResource Include="Resources\mipmap-ldpi\ic_notification.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xhdpi\banner.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher_foreground.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xhdpi\ic_launcher_round.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xhdpi\ic_notification.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-mdpi\banner.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-ldpi\banner.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-hdpi\banner.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xxhdpi\banner.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\mipmap-xxxhdpi\banner.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
1 change: 1 addition & 0 deletions VpnHood.Client.App/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class UserSettings
public string CultureName { get; set; } = "en";
public Guid? DefaultClientProfileId { get; set; }
public int MaxReconnectCount { get; set; } = 3;
public int MaxDatagramChannelCount { get; set; } = new ClientOptions().MaxDatagramChannelCount;
public string[]? IpGroupFilters { get; set; }
public FilterMode IpGroupFiltersMode { get; set; } = FilterMode.All;
public IpRange[]? CustomIpRanges { get; set; }
Expand Down
1 change: 1 addition & 0 deletions VpnHood.Client.App/VpnHoodApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ private async Task ConnectInternal(IPacketCapture packetCapture, Guid tokenId, s
ExcludeLocalNetwork = UserSettings.ExcludeLocalNetwork,
IncludeIpRanges = await GetIncludeIpRanges(UserSettings.IpGroupFiltersMode, UserSettings.IpGroupFilters),
PacketCaptureIncludeIpRanges = GetIncludeIpRanges(UserSettings.PacketCaptureIpRangesFilterMode, UserSettings.PacketCaptureIpRanges),
MaxDatagramChannelCount = UserSettings.MaxDatagramChannelCount
};
if (_socketFactory != null) clientOptions.SocketFactory = _socketFactory;
if (userAgent != null) clientOptions.UserAgent = userAgent;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions VpnHood.Client/VpnHoodClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public VpnHoodClient(IPacketCapture packetCapture, Guid clientId, Token token, C
_tcpProxyHost = new TcpProxyHost(this, options.TcpProxyLoopbackAddressIpV4, options.TcpProxyLoopbackAddressIpV6);

// Create simple disposable objects
_cancellationTokenSource = new();
_cancellationTokenSource = new CancellationTokenSource();
_cancellationToken = _cancellationTokenSource.Token;

#if DEBUG
Expand Down Expand Up @@ -377,7 +377,7 @@ private void PacketCapture_OnPacketReceivedFromInbound(object sender, Device.Pac
// send packets
if (passthruPackets.Count > 0) _packetCapture.SendPacketToOutbound(passthruPackets.ToArray());
if (proxyPackets.Count > 0) _proxyManager.SendPacket(proxyPackets.ToArray());
if (tunnelPackets.Count > 0) Tunnel.SendPacket(tunnelPackets.ToArray()).Wait();
if (tunnelPackets.Count > 0) Tunnel.SendPacket(tunnelPackets.ToArray()).Wait(_cancellationToken);
if (tcpHostPackets.Count > 0) _packetCapture.SendPacketToInbound(_tcpProxyHost.ProcessOutgoingPacket(tcpHostPackets.ToArray()));
}
}
Expand Down
17 changes: 17 additions & 0 deletions VpnHood.Common/Net/IPAddressUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,22 @@ public static bool IsMinValue(IPAddress ipAddress)
_ => throw new NotSupportedException($"{ipAddress.AddressFamily} is not supported!")
};
}

public static IPAddress Anonymize(IPAddress ipAddress)
{
if (ipAddress.AddressFamily == AddressFamily.InterNetwork)
{
var bytes = ipAddress.GetAddressBytes();
bytes[^1] = 0;
return new IPAddress(bytes);
}
else
{
var bytes = ipAddress.GetAddressBytes();
for (var i=6; i< bytes.Length; i++)
bytes[i] = 0;
return new IPAddress(bytes);
}
}
}
}
Loading

0 comments on commit db3cc82

Please sign in to comment.