]> jfr.im git - irc/rizon/acid.git/commitdiff
SWEBIRC and REALHOST processing
authorOrillion <redacted>
Sat, 29 Aug 2015 17:49:42 +0000 (13:49 -0400)
committerAdam <redacted>
Sat, 29 Aug 2015 17:49:42 +0000 (13:49 -0400)
acid/src/main/java/net/rizon/acid/core/Acidictive.java
acid/src/main/java/net/rizon/acid/core/Event.java
acid/src/main/java/net/rizon/acid/core/Protocol.java
acid/src/main/java/net/rizon/acid/core/User.java
acid/src/main/java/net/rizon/acid/messages/Encap.java

index 0d842f4bd96eb05659c0fc06c7c67232dc111232..c9cb07bc9cf56cd9ff069775899fe0866146464b 100644 (file)
@@ -555,6 +555,12 @@ public class Acidictive extends AcidCore
                        e.onChanModes(creator, chan, modes);
        }
 
+       public static void onWebIRC(Server source, String operation, String uid, String realhost, String sockhost, String webircPassword, String webircUsername, String fakeHost, String fakeIp)
+       {
+               for (Event e : Event.getEvents())
+                       e.onWebIRC(source, operation, uid, realhost, sockhost, webircPassword, webircUsername, fakeHost, fakeIp);
+       }
+
        public static void setMode(String source, String target, String modes)
        {
                Channel c = Channel.findChannel(target);
index 7c104a64cdde4c3f7e6cf5ebc8acefdbce3e3713..6010735432832269f1c0005cc3fee38f3344d3f8 100644 (file)
@@ -45,6 +45,7 @@ public abstract class Event
 
        public void onUserMode(User user, String oldmodes, String newmodes) { }
        public void onChanModes(String prefix, Channel chan, String modes) { }
+       public void onWebIRC(Server source, String operation, String uid, String realhost, String sockhost, String webircPassword, String webircUsername, String fakeHost, String fakeIp) { };
 
        public void onRehash() throws Exception { }
 
index 9adaf2caf47fd97dbff303ed83252b8468b61cb6..dcc59bc8c683dee64a39ea656faa333c0e8e4c8c 100644 (file)
@@ -235,4 +235,17 @@ public class Protocol
        {
                encap(target.getServer().getName(), "CHGCLASS", target.getUID() + " " + clazz);
        }
+
+       public static void chgrealhost(User target, String sockhost, String realhost)
+       {
+               encap(target.getServer().getName(), "CHGREALHOST", target.getUID() + " " + sockhost + " " + realhost);
+       }
+
+       public static void swebirc(String flag, String uid, String host, String ip, String password, String name, String fakeSockHost, String fakeHost, String ... args)
+       {
+               if (flag.equalsIgnoreCase("REQ") || flag.equalsIgnoreCase("ACK") || flag.equalsIgnoreCase("NAK"))
+               {
+                       encap("*", "SWEBIRC", flag.toUpperCase() + " " + uid + " " + host + " " + ip + " * * " + password + " " + name + " " + fakeSockHost + " :" + fakeHost);
+               }
+       }
 }
index cbc15f0593cbfdf4a4bbd92bd3016b78a0763616..5d3ef64439a7339fadb47394e6de3f5a1dd13359 100644 (file)
@@ -164,6 +164,12 @@ public class User implements Comparable<User>
                return s;
        }
 
+       public void setRealhost(String ip, String host)
+       {
+               this.ip = ip;
+               this.host = host;
+       }
+
        public void setFlags(String flags)
        {
                this.flags = flags;
index 1cd2a0dd274594db113a64dc691befadafddd387..580cc394873f39294ac6342780debef8082c3ccb 100644 (file)
@@ -1,6 +1,9 @@
 package net.rizon.acid.messages;
 
+import java.util.ArrayList;
+import java.util.List;
 import net.rizon.acid.core.AcidCore;
+import net.rizon.acid.core.Acidictive;
 import net.rizon.acid.core.Message;
 import net.rizon.acid.core.Server;
 import net.rizon.acid.core.User;
@@ -67,5 +70,30 @@ public class Encap extends Message
 
                        user.setAuthFlags(params[3]);
                }
+               else if (params[1].equals("SWEBIRC"))
+               {
+                       int parc = params.length;
+                       if (parc < 10)
+                               return;
+                       
+                       Acidictive.onWebIRC(source,
+                               params[2], // operation
+                               params[3], // uid
+                               params[4], // realhost
+                               params[5], // sockhost
+                               params[parc - 4], // webirc password
+                               params[parc - 3], // webirc username
+                               params[parc - 2], // requested host
+                               params[parc - 1] // requested ip
+                       );
+               }
+               else if (params[1].equals("CHGREALHOST"))
+               {
+                       User user = User.findUser(params[2]);
+                       if (user == null)
+                               return;
+
+                       user.setRealhost(params[3], params[4]);
+               }
        }
 }
\ No newline at end of file