Skip to content

Commit f7c0e5c

Browse files
committed
reformat code
1 parent 524f6c1 commit f7c0e5c

39 files changed

+2549
-2577
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest
3-
xmlns:android="http://schemas.android.com/apk/res/android"
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
43
package="com.vm.shadowsocks">
54

6-
<uses-permission android:name="android.permission.INTERNET"/>
7-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
7+
88
<application
99
android:allowBackup="true"
1010
android:icon="@drawable/shadowsocks"
@@ -17,16 +17,16 @@
1717
android:label="@string/app_name"
1818
android:launchMode="singleTask">
1919
<intent-filter>
20-
<action android:name="android.intent.action.MAIN"/>
21-
<category android:name="android.intent.category.LAUNCHER"/>
20+
<action android:name="android.intent.action.MAIN" />
21+
<category android:name="android.intent.category.LAUNCHER" />
2222
</intent-filter>
2323
</activity>
2424

2525
<service
2626
android:name="com.vm.shadowsocks.core.LocalVpnService"
2727
android:permission="android.permission.BIND_VPN_SERVICE">
2828
<intent-filter>
29-
<action android:name="android.net.VpnService"/>
29+
<action android:name="android.net.VpnService" />
3030
</intent-filter>
3131
</service>
3232
</application>

app/src/main/java/com/vm/shadowsocks/core/ChinaIpMaskManager.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,41 @@
1010

1111
public class ChinaIpMaskManager {
1212

13-
static SparseIntArray ChinaIpMaskDict = new SparseIntArray(3000);
14-
static SparseIntArray MaskDict = new SparseIntArray();
15-
16-
public static boolean isIPInChina(int ip){
17-
boolean found=false;
18-
for (int i = 0; i < MaskDict.size(); i++) {
19-
int mask=MaskDict.keyAt(i);
20-
int networkIP = ip & mask;
21-
int mask2 = ChinaIpMaskDict.get(networkIP);
22-
if(mask2==mask){
23-
found= true;
24-
break;
25-
}
26-
}
27-
return found;
28-
}
29-
30-
public static void loadFromFile(InputStream inputStream){
31-
int count=0;
32-
try {
33-
byte[] buffer=new byte[4096];
34-
while((count = inputStream.read(buffer))>0){
35-
for (int i = 0; i < count; i+=8) {
36-
int ip = CommonMethods.readInt(buffer, i);
37-
int mask = CommonMethods.readInt(buffer, i+4);
38-
ChinaIpMaskDict.put(ip, mask);
39-
MaskDict.put(mask, mask);
40-
//System.out.printf("%s/%s\n", CommonMethods.IP2String(ip),CommonMethods.IP2String(mask));
41-
}
42-
}
43-
inputStream.close();
44-
System.out.printf("ChinaIpMask records count: %d\n", ChinaIpMaskDict.size());
45-
} catch (IOException e) {
46-
// TODO Auto-generated catch block
47-
e.printStackTrace();
48-
}
49-
}
13+
static SparseIntArray ChinaIpMaskDict = new SparseIntArray(3000);
14+
static SparseIntArray MaskDict = new SparseIntArray();
15+
16+
public static boolean isIPInChina(int ip) {
17+
boolean found = false;
18+
for (int i = 0; i < MaskDict.size(); i++) {
19+
int mask = MaskDict.keyAt(i);
20+
int networkIP = ip & mask;
21+
int mask2 = ChinaIpMaskDict.get(networkIP);
22+
if (mask2 == mask) {
23+
found = true;
24+
break;
25+
}
26+
}
27+
return found;
28+
}
29+
30+
public static void loadFromFile(InputStream inputStream) {
31+
int count = 0;
32+
try {
33+
byte[] buffer = new byte[4096];
34+
while ((count = inputStream.read(buffer)) > 0) {
35+
for (int i = 0; i < count; i += 8) {
36+
int ip = CommonMethods.readInt(buffer, i);
37+
int mask = CommonMethods.readInt(buffer, i + 4);
38+
ChinaIpMaskDict.put(ip, mask);
39+
MaskDict.put(mask, mask);
40+
//System.out.printf("%s/%s\n", CommonMethods.IP2String(ip),CommonMethods.IP2String(mask));
41+
}
42+
}
43+
inputStream.close();
44+
System.out.printf("ChinaIpMask records count: %d\n", ChinaIpMaskDict.size());
45+
} catch (IOException e) {
46+
// TODO Auto-generated catch block
47+
e.printStackTrace();
48+
}
49+
}
5050
}

0 commit comments

Comments
 (0)