Skip to content

Commit

Permalink
Add full support for the random server port. Closes #19
Browse files Browse the repository at this point in the history
jp-bennett committed Sep 12, 2015

Verified

This commit was signed with the committer’s verified signature. The key has expired.
chfast Paweł Bylica
1 parent 5d7f45f commit d4aab86
Showing 4 changed files with 37 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -32,8 +32,8 @@ android {
applicationId "org.cipherdyne.fwknop2"
minSdkVersion 15
targetSdkVersion 19
versionCode 8
versionName "1.1-Beta-2"
versionCode 9
versionName "1.1"
ndk {
moduleName 'libfwknop'
ldLibs 'log'
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
@@ -78,6 +79,7 @@ public class ConfigDetailFragment extends Fragment {
LinearLayout lay_AccessPort;
LinearLayout lay_fwTimeout;
LinearLayout lay_sshcmd;
LinearLayout lay_serverPort;
TextView txt_ssh_cmd;
String configtype = "Open Port";
Spinner spn_protocol;
@@ -95,6 +97,7 @@ public class ConfigDetailFragment extends Fragment {
TextView txt_HMAC ;
CheckBox chkb64hmac ;
CheckBox chkblegacy;
CheckBox chkbrandom;

/**
* The fragment argument representing the item ID that this fragment
@@ -243,7 +246,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
config.NICK_NAME = txt_NickName.getText().toString();
config.SERVER_IP = txt_server_ip.getText().toString();
config.SERVER_PORT = txt_server_port.getText().toString();
if (chkbrandom.isChecked()) {
config.SERVER_PORT = "random";
} else {
config.SERVER_PORT = txt_server_port.getText().toString();
}
config.SSH_CMD = "";
if (spn_ssh.getSelectedItem().toString().equalsIgnoreCase("SSH Uri")) {
config.SSH_CMD = txt_ssh_cmd.getText().toString();
@@ -329,6 +336,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
lay_natIP = (LinearLayout) rootView.findViewById(R.id.natipsl);
lay_natport = (LinearLayout) rootView.findViewById(R.id.natportsl);
lay_serverCMD = (LinearLayout) rootView.findViewById(R.id.servercmdsl);
lay_serverPort = (LinearLayout) rootView.findViewById(R.id.destPortl);
txt_ports = (TextView) rootView.findViewById(R.id.AccessPorts);
txt_server_ip = (TextView) rootView.findViewById(R.id.destIP);
txt_server_port = (TextView) rootView.findViewById(R.id.destPort);
@@ -345,6 +353,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
chkb64hmac = (CheckBox) rootView.findViewById(R.id.chkb64hmac);
chkb64key = (CheckBox) rootView.findViewById(R.id.chkb64key);
chkblegacy = (CheckBox) rootView.findViewById(R.id.chkblegacy);
chkbrandom = (CheckBox) rootView.findViewById(R.id.chkbrandom);
spn_allowip = (Spinner) rootView.findViewById(R.id.allowip);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
R.array.spinner_options, android.R.layout.simple_spinner_item);
@@ -364,6 +373,19 @@ public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
public void onNothingSelected(AdapterView<?> parent) {
}
});
chkbrandom.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean ischecked) {
if (ischecked) {
lay_serverPort.setVisibility(View.GONE);
} else {
lay_serverPort.setVisibility(View.VISIBLE);
}
}
});




spn_protocol = (Spinner) rootView.findViewById(R.id.spn_protocol);
ArrayAdapter<CharSequence> adapter_protocol = ArrayAdapter.createFromResource(getActivity(),
@@ -508,7 +530,10 @@ public void onNothingSelected(AdapterView<?> parent) {
}
txt_ports.setText(config.PORTS);
txt_server_ip.setText(config.SERVER_IP);
txt_server_port.setText(config.SERVER_PORT);
txt_server_port.setText(config.SERVER_PORT); // check for random
if (config.SERVER_PORT.equalsIgnoreCase("random")){
chkbrandom.setChecked(true);
}
txt_server_time.setText(config.SERVER_TIMEOUT);
txt_KEY.setText(config.KEY);
if (config.KEY_BASE64) {
7 changes: 7 additions & 0 deletions app/src/main/res/layout/fragment_config_detail.xml
Original file line number Diff line number Diff line change
@@ -63,6 +63,13 @@
android:layout_height="wrap_content"
android:text="@string/config_legacy"
/>
<CheckBox
android:id="@+id/chkbrandom"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/config_random"
/>
<LinearLayout android:id="@+id/destPortl"
android:orientation="horizontal"
android:layout_width="fill_parent"
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -108,6 +108,7 @@
<string name="spa_failure">Failure generating SPA data</string>
<string name="my_ip_source_error">URL must be in the form of http://whatismyip.akamai.com or https://api.ipify.org</string>
<string name="config_legacy">Use Legacy Mode</string>
<string name="config_random">Use Random Server Port</string>
<string name="config_protocol">Protocol:</string>
<string name="menu_send_knock">Send Knock</string>
</resources>

0 comments on commit d4aab86

Please sign in to comment.