Compare commits

...

3 Commits

Author SHA1 Message Date
DarkFeather 8a80ff8d93
Adding r.ip to help 2023-01-20 14:23:39 -06:00
DarkFeather 2b85ffac49
Generalizing IP curl 2023-01-20 14:23:26 -06:00
DarkFeather 24825cced3
Moving netlistener onto a unique config block 2023-01-20 08:36:34 -06:00
4 changed files with 19 additions and 11 deletions

View File

@ -26,7 +26,7 @@ namespace AniNIX.TheRaven {
public List<String> channels; //This is the list of channels to join
public List<String> whitelist; //This is the list of admin users.
public List<String> blacklist; // This is the list of blocked people.
public String helpText = "Available commands are r.d <dice test>, r.heartbeat, r.magic8, r.math <math problem>, r.msg <memo for admin>, r.raven, r.searches, r.tinyurl <url>, r.wikidiff \"one\" \"other\", and r.uptime";
public String helpText = "Available commands are r.d <dice test>, r.ip, r.magic8, r.math <math problem>, r.msg <memo for admin>, r.raven, r.searches, r.tinyurl <url>, r.wikidiff \"one\" \"other\", and r.uptime";
// This is the text to send when people ask for help -- this is configurable to allow for skinning
public List<String> searches; //These are the searches
public String searchesIndex; //This is the helptext for the searches
@ -75,11 +75,12 @@ namespace AniNIX.TheRaven {
ReportMessage.Log(Verbosity.Verbose,"Reading login info");
try {
Dictionary<String,String> loginDefaults = conf.ReadSection("Login");
Dictionary<String,String> apiDefaults = conf.ReadSection("API");
this.Host = loginDefaults["host"];
this.Port = Int32.Parse(loginDefaults["port"]);
this.Nick = loginDefaults["username"];
this._nickServPass = loginDefaults["password"];
this._netListener = new RavenNetListener(loginDefaults["password"]);
this._netListener = new RavenNetListener(apiDefaults["password"],Int32.Parse(apiDefaults["port"]));
channels=new List<String>();
foreach (String channel in conf.ReadSectionLines("Rooms")) {
@ -268,7 +269,7 @@ namespace AniNIX.TheRaven {
/// Read from the connection, and for each message act appropriately.
/// </summary>
public void LoopOnTraffic() {
ReportMessage.Log(Verbosity.Verbose,"Looping on trafffic now! We're useful!");
ReportMessage.Log(Verbosity.Verbose,"Looping on traffic now! We're useful!");
// Start a network listener to allow relaying traffic via ncat into IRCd.
this._netListener.NetListener(this._connection);
// Loop on main connect to ircd

View File

@ -127,7 +127,7 @@ namespace AniNIX.TheRaven {
connection.Write(send);
return;
case "r.ip":
send.PrivMsg(ExecuteCommand.Run("curl -s 10.0.1.1:80 | grep \"WAN IP\" | cut -f 7 -d \">\" | cut -f 1 -d \"<\""),(incoming.target.Equals(theRaven.Nick))?incoming.user:incoming.target);
send.PrivMsg(ExecuteCommand.Run("curl -s $(ip r list | grep default | cut -f 3 -d \" \"):80 | grep \"WAN IP\" | cut -f 13 -d \">\" | cut -f 1 -d \"<\""),(incoming.target.Equals(theRaven.Nick))?incoming.user:incoming.target);
connection.Write(send);
return;
case "r.searches":

View File

@ -13,6 +13,7 @@ namespace AniNIX.TheRaven {
public class RavenNetListener {
private String _key;
private int _port;
private Connection _ircdConnection;
private void _RavenSend(Connection ircdConnection, String channel, String message) {
@ -26,9 +27,9 @@ namespace AniNIX.TheRaven {
while (true) {
try
{
// Open a new listener on localhost port 9501
IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
TcpListener listener = new TcpListener(ipAddress, 9501);
// Open a new listener on port
IPAddress ipAddress = IPAddress.Parse("0.0.0.0");
TcpListener listener = new TcpListener(ipAddress, this._port );
listener.Start();
// Accept all connections
while (true)
@ -40,6 +41,7 @@ namespace AniNIX.TheRaven {
string received = "";
for (int i = 0; i < size; i++)
received += Convert.ToChar(data[i]);
ReportMessage.Log(Verbosity.Verbose,String.Format("RavenNetListener received: [{0}]",received));
String[] bySpace = received.Split(' ');
// If the key matches, ...
if (this._key.Equals(bySpace[0])) {
@ -73,8 +75,9 @@ namespace AniNIX.TheRaven {
ReportMessage.Log(Verbosity.Verbose,"Started.");
}
public RavenNetListener(String key) {
public RavenNetListener(String key, int port) {
this._key = key;
this._port = port;
}
}
}

View File

@ -1,18 +1,22 @@
[ Login ]
host=localhost
port=6667
username=TheRaven
username=TheRavenTest
password=password
[ API ]
port=9902
password=sample
[ Whitelist ]
Admin
DarkFeather
[ Blacklist ]
[ Notifications ]
[ Rooms ]
TheRaven
test123
[ Searches ]
r.google|http://google.com/search?q=|+|Google