mirror of
https://github.com/moparisthebest/SSLDroid
synced 2025-01-06 19:08:00 -05:00
Added local port collision check to the tunnel details input
validation Signed-off-by: Balint Kovacs <blint@blint.hu>
This commit is contained in:
parent
8d35c15a02
commit
a094fa8be1
@ -56,6 +56,7 @@ public class SSLDroid extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor.deactivate();
|
cursor.deactivate();
|
||||||
|
cursor.close();
|
||||||
dbHelper.close();
|
dbHelper.close();
|
||||||
createNotification(0, true, "SSLDroid is running", "Started and serving "+tunnelcount+" tunnels");
|
createNotification(0, true, "SSLDroid is running", "Started and serving "+tunnelcount+" tunnels");
|
||||||
Log.d(TAG, "SSLDroid Service Started");
|
Log.d(TAG, "SSLDroid Service Started");
|
||||||
@ -73,6 +74,7 @@ public class SSLDroid extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
dbHelper.close();
|
||||||
try {
|
try {
|
||||||
for (TcpProxy proxy : tp) {
|
for (TcpProxy proxy : tp) {
|
||||||
proxy.stop();
|
proxy.stop();
|
||||||
|
@ -73,7 +73,6 @@ public class SSLDroidTunnelDetails extends Activity {
|
|||||||
populateFields();
|
populateFields();
|
||||||
confirmButton.setOnClickListener(new View.OnClickListener() {
|
confirmButton.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
//TODO: put local port collision check here
|
|
||||||
if (name.getText().length() == 0) {
|
if (name.getText().length() == 0) {
|
||||||
Toast.makeText(getBaseContext(), "Required tunnel name parameter not setup, skipping save", 5).show();
|
Toast.makeText(getBaseContext(), "Required tunnel name parameter not setup, skipping save", 5).show();
|
||||||
return;
|
return;
|
||||||
@ -95,7 +94,20 @@ public class SSLDroidTunnelDetails extends Activity {
|
|||||||
if (cPort < 1025 || cPort > 65535) {
|
if (cPort < 1025 || cPort > 65535) {
|
||||||
Toast.makeText(getBaseContext(), "Local port parameter not in valid range (1025-65535)", 5).show();
|
Toast.makeText(getBaseContext(), "Local port parameter not in valid range (1025-65535)", 5).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//check if the requested port is colliding with a port already configured for another tunnel
|
||||||
|
SSLDroidDbAdapter dbHelper = new SSLDroidDbAdapter(getBaseContext());
|
||||||
|
dbHelper.open();
|
||||||
|
Cursor cursor = dbHelper.fetchAllLocalPorts();
|
||||||
|
startManagingCursor(cursor);
|
||||||
|
while (cursor.moveToNext()){
|
||||||
|
String cDbName = cursor.getString(cursor.getColumnIndexOrThrow(SSLDroidDbAdapter.KEY_NAME));
|
||||||
|
int cDbPort = cursor.getInt(cursor.getColumnIndexOrThrow(SSLDroidDbAdapter.KEY_LOCALPORT));
|
||||||
|
if (cPort == cDbPort){
|
||||||
|
Toast.makeText(getBaseContext(), "Local port already configured in tunnel '"+cDbName+"', please change...", 5).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//remote host validation
|
//remote host validation
|
||||||
if (remotehost.getText().length() == 0){
|
if (remotehost.getText().length() == 0){
|
||||||
|
@ -68,7 +68,7 @@ public class SSLDroidDbAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a Cursor over the list of all tunnel in the database
|
* Return a Cursor over the list of all tunnels in the database
|
||||||
*
|
*
|
||||||
* @return Cursor over all notes
|
* @return Cursor over all notes
|
||||||
*/
|
*/
|
||||||
@ -78,6 +78,16 @@ public class SSLDroidDbAdapter {
|
|||||||
KEY_PKCSPASS }, null, null, null, null, null);
|
KEY_PKCSPASS }, null, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a Cursor over the list of all tunnels in the database
|
||||||
|
*
|
||||||
|
* @return Cursor over all notes
|
||||||
|
*/
|
||||||
|
public Cursor fetchAllLocalPorts() {
|
||||||
|
return database.query(DATABASE_TABLE, new String[] { KEY_NAME,
|
||||||
|
KEY_LOCALPORT }, null, null, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a Cursor positioned at the defined tunnel
|
* Return a Cursor positioned at the defined tunnel
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user