summary refs log tree commit diff stats
path: root/src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java')
-rw-r--r--src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java b/src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java
index 1c55bc6..57424dd 100644
--- a/src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java
+++ b/src/main/java/ganarchy/friendcode/sam/I2PSamStateMachine.java
@@ -13,22 +13,12 @@ import java.util.Iterator;
 import java.util.Objects;
 
 public abstract class I2PSamStateMachine implements Closeable {
-    // FIXME user/password from config
-    private static final I2PSamCommand HELLO_MESSAGE = new I2PSamCommand(
-        "HELLO", "VERSION",
-        ImmutableMap.of(
-            "MIN", "3.2",
-            "USER", "minecraft_friendcode",
-            "PASSWORD", "friendcode"
-        )
-    );
     private Socket samSocket;
     private PushbackReader reader;
     private OutputStreamWriter writer;
     private final ArrayDeque<I2PSamCommand> queue = new ArrayDeque<>();
     private boolean started;
     private boolean connected;
-    private String id;
 
     protected I2PSamStateMachine() {
     }
@@ -69,8 +59,15 @@ public abstract class I2PSamStateMachine implements Closeable {
 
 
             // send HELLO
-            // FIXME let the user change the credentials
-            this.sendCommand(HELLO_MESSAGE);
+            var auth = I2PSamAuthUtil.getAuthPair();
+            this.sendCommand(new I2PSamCommand(
+                "HELLO", "VERSION",
+                ImmutableMap.of(
+                    "MIN", "3.2",
+                    "USER", auth.user(),
+                    "PASSWORD", auth.password()
+                )
+            ));
             return "OK".equals(this.getCommand("HELLO", "REPLY").parameters().get("RESULT"));
         } catch (IOException e) {
             return false;