-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GUI refactoring, experimental IP utilities
- Loading branch information
Showing
10 changed files
with
111 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package convex.gui.wallet; | ||
|
||
import convex.api.Convex; | ||
import convex.gui.components.AbstractGUI; | ||
|
||
@SuppressWarnings("serial") | ||
public class SwapPanel extends AbstractGUI { | ||
|
||
protected Convex convex; | ||
|
||
private SwapPanel(String title) { | ||
super(title); | ||
} | ||
|
||
public SwapPanel(Convex convex) { | ||
this("Token Swap for account "+convex.getAddress()); | ||
this.convex=convex; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package convex.net; | ||
|
||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.net.URI; | ||
import java.net.UnknownHostException; | ||
import java.net.http.HttpClient; | ||
import java.net.http.HttpRequest; | ||
import java.net.http.HttpResponse; | ||
|
||
public class IPUtils { | ||
|
||
public static InetAddress tryGetIP() throws InterruptedException { | ||
|
||
String s=tryGetWTF().trim(); | ||
if (s!=null) { | ||
try { | ||
InetAddress i= InetAddress.getByName(s); | ||
return i; | ||
} catch (UnknownHostException e) { | ||
// continue | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public static String tryGetWTF() throws InterruptedException { | ||
HttpClient client = HttpClient.newHttpClient(); | ||
|
||
HttpRequest request = HttpRequest.newBuilder( | ||
URI.create("https://wtfismyip.com/text")) | ||
.header("accept", "text/plain") | ||
.build(); | ||
|
||
HttpResponse<String> response; | ||
try { | ||
response = client.send(request, HttpResponse.BodyHandlers.ofString()); | ||
String text=response.body(); | ||
return text; | ||
} catch (IOException e) { | ||
return null; | ||
} | ||
} | ||
|
||
public static void main(String[] args) throws InterruptedException { | ||
System.out.println(tryGetIP()); | ||
|
||
System.out.println(tryGetIP()); | ||
} | ||
} |