Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
c54745e2
Commit
c54745e2
authored
Jan 16, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt to simple-obfs plugin options parser
parent
e3cf54f7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
plugin/src/main/java/com/github/shadowsocks/plugin/PluginOptions.java
...ain/java/com/github/shadowsocks/plugin/PluginOptions.java
+20
-12
No files found.
plugin/src/main/java/com/github/shadowsocks/plugin/PluginOptions.java
View file @
c54745e2
...
@@ -23,12 +23,11 @@ public final class PluginOptions extends HashMap<String, String> {
...
@@ -23,12 +23,11 @@ public final class PluginOptions extends HashMap<String, String> {
super
(
initialCapacity
,
loadFactor
);
super
(
initialCapacity
,
loadFactor
);
}
}
p
ublic
PluginOptions
(
String
options
)
throws
IllegalArgumentException
{
p
rivate
PluginOptions
(
String
options
,
boolean
parseId
)
throws
IllegalArgumentException
{
if
(
TextUtils
.
isEmpty
(
options
))
return
;
if
(
TextUtils
.
isEmpty
(
options
))
return
;
final
StringTokenizer
tokenizer
=
new
StringTokenizer
(
options
,
"\\=;"
,
true
);
final
StringTokenizer
tokenizer
=
new
StringTokenizer
(
options
,
"\\=;"
,
true
);
final
StringBuilder
current
=
new
StringBuilder
();
final
StringBuilder
current
=
new
StringBuilder
();
String
key
=
null
;
String
key
=
null
;
boolean
firstEntry
=
true
;
while
(
tokenizer
.
hasMoreTokens
())
{
while
(
tokenizer
.
hasMoreTokens
())
{
String
nextToken
=
tokenizer
.
nextToken
();
String
nextToken
=
tokenizer
.
nextToken
();
if
(
"\\"
.
equals
(
nextToken
))
current
.
append
(
tokenizer
.
nextToken
());
if
(
"\\"
.
equals
(
nextToken
))
current
.
append
(
tokenizer
.
nextToken
());
...
@@ -36,22 +35,28 @@ public final class PluginOptions extends HashMap<String, String> {
...
@@ -36,22 +35,28 @@ public final class PluginOptions extends HashMap<String, String> {
if
(
key
!=
null
)
throw
new
IllegalArgumentException
(
"Duplicate keys in "
+
options
);
if
(
key
!=
null
)
throw
new
IllegalArgumentException
(
"Duplicate keys in "
+
options
);
key
=
current
.
toString
();
key
=
current
.
toString
();
current
.
setLength
(
0
);
current
.
setLength
(
0
);
}
else
if
(
";"
.
equals
(
nextToken
))
{
}
else
if
(
";"
.
equals
(
nextToken
))
if
(
key
!=
null
)
{
if
(
key
!=
null
)
{
put
(
key
,
current
.
toString
());
put
(
key
,
current
.
toString
());
key
=
null
;
key
=
null
;
}
else
if
(
firstEntry
)
id
=
current
.
toString
();
}
else
if
(
parseId
)
{
else
throw
new
IllegalArgumentException
(
"Value missing in "
+
options
);
id
=
current
.
toString
();
firstEntry
=
false
;
parseId
=
false
;
}
else
{
put
(
current
.
toString
(),
null
);
current
.
setLength
(
0
);
}
}
}
}
}
}
public
PluginOptions
(
String
options
)
throws
IllegalArgumentException
{
this
(
options
,
true
);
}
public
PluginOptions
(
String
id
,
String
options
)
throws
IllegalArgumentException
{
public
PluginOptions
(
String
id
,
String
options
)
throws
IllegalArgumentException
{
this
(
options
);
this
(
options
,
false
);
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
String
id
=
""
;
public
String
id
;
private
static
void
append
(
StringBuilder
result
,
String
str
)
{
private
static
void
append
(
StringBuilder
result
,
String
str
)
{
for
(
int
i
=
0
;
i
<
str
.
length
();
++
i
)
{
for
(
int
i
=
0
;
i
<
str
.
length
();
++
i
)
{
...
@@ -65,11 +70,14 @@ public final class PluginOptions extends HashMap<String, String> {
...
@@ -65,11 +70,14 @@ public final class PluginOptions extends HashMap<String, String> {
public
String
toString
(
boolean
trimId
)
{
public
String
toString
(
boolean
trimId
)
{
final
StringBuilder
result
=
new
StringBuilder
();
final
StringBuilder
result
=
new
StringBuilder
();
if
(!
trimId
)
if
(
TextUtils
.
isEmpty
(
id
))
return
""
;
else
append
(
result
,
id
);
if
(!
trimId
)
if
(
TextUtils
.
isEmpty
(
id
))
return
""
;
else
append
(
result
,
id
);
for
(
Entry
<
String
,
String
>
entry
:
entrySet
())
if
(
entry
.
getValue
()
!=
null
)
{
for
(
Entry
<
String
,
String
>
entry
:
entrySet
())
{
if
(
result
.
length
()
>
0
)
result
.
append
(
';'
);
if
(
result
.
length
()
>
0
)
result
.
append
(
';'
);
append
(
result
,
entry
.
getKey
());
append
(
result
,
entry
.
getKey
());
String
value
=
entry
.
getValue
();
if
(
value
!=
null
)
{
result
.
append
(
'='
);
result
.
append
(
'='
);
append
(
result
,
entry
.
getValue
());
append
(
result
,
value
);
}
}
}
return
result
.
toString
();
return
result
.
toString
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment