@@ -23,22 +23,24 @@ public class Local {
23
23
private LocalProcess proc = null ;
24
24
25
25
private final Map <String , String > parameters ;
26
+ private final Map <String , String > avoidValueParameters ;
26
27
27
28
public Local () {
29
+ avoidValueParameters = new HashMap <String , String >();
30
+ avoidValueParameters .put ("v" , "-vvv" );
31
+ avoidValueParameters .put ("force" , "-force" );
32
+ avoidValueParameters .put ("forcelocal" , "-forcelocal" );
33
+ avoidValueParameters .put ("onlyAutomate" , "-onlyAutomate" );
34
+ avoidValueParameters .put ("forceproxy" , "-forceproxy" );
35
+
28
36
parameters = new HashMap <String , String >();
29
- parameters .put ("v" , "-vvv" );
30
37
parameters .put ("f" , "-f" );
31
- parameters .put ("force" , "-force" );
32
38
parameters .put ("only" , "-only" );
33
- parameters .put ("forcelocal" , "-forcelocal" );
34
39
parameters .put ("localIdentifier" , "-localIdentifier" );
35
- parameters .put ("onlyAutomate" , "-onlyAutomate" );
36
40
parameters .put ("proxyHost" , "-proxyHost" );
37
41
parameters .put ("proxyPort" , "-proxyPort" );
38
42
parameters .put ("proxyUser" , "-proxyUser" );
39
43
parameters .put ("proxyPass" , "-proxyPass" );
40
- parameters .put ("forceproxy" , "-forceproxy" );
41
- parameters .put ("hosts" , "-hosts" );
42
44
}
43
45
44
46
/**
@@ -75,7 +77,7 @@ public void start(Map<String, String> options) throws Exception {
75
77
76
78
JSONObject obj = new JSONObject (!stdout .equals ("" ) ? stdout : stderr );
77
79
if (!obj .getString ("state" ).equals ("connected" )){
78
- throw new LocalException (obj .getString ("message" ));
80
+ throw new LocalException (obj .getJSONObject ( "message" ). getString ("message" ));
79
81
}
80
82
else {
81
83
pid = obj .getInt ("pid" );
@@ -124,13 +126,17 @@ private void makeCommand(Map<String, String> options, String opCode) {
124
126
if (IGNORE_KEYS .contains (parameter )) {
125
127
continue ;
126
128
}
127
- if (parameters .get (parameter ) != null ) {
128
- command .add (parameters .get (parameter ));
129
+ if (avoidValueParameters .get (parameter ) != null && opt . getValue (). trim (). toLowerCase () != "false" ) {
130
+ command .add (avoidValueParameters .get (parameter ));
129
131
} else {
130
- command .add ("-" + parameter );
131
- }
132
- if (opt .getValue () != null ) {
133
- command .add (opt .getValue ().trim ());
132
+ if (parameters .get (parameter ) != null ) {
133
+ command .add (parameters .get (parameter ));
134
+ } else {
135
+ command .add ("-" + parameter );
136
+ }
137
+ if (opt .getValue () != null ) {
138
+ command .add (opt .getValue ().trim ());
139
+ }
134
140
}
135
141
}
136
142
}
0 commit comments