jnewing / anope

Anope IRC Services
https://www.anope.org
0 stars 0 forks source link

IP address beyond +x for user with ns info? #3

Open ahopelesshadow opened 4 months ago

ahopelesshadow commented 4 months ago

when using the xmlrpc modules in anope, you can run the following via python:

import xmlrpc.client
anope_url = "http://127.0.0.1/xmlrpc"
xclient = xmlrpc.client.ServerProxy(anope_url)
whois = xclient.user("Username")

and the return would be similiar to the following dict. {'account': 'NickName', 'channels': 'whatever', 'chost': 'Cloak.xxxxx.hostmask.ext', 'host': 'sub.domain.ext', 'ident': 'NickName', 'ip': '127.0.0.1', 'nick': 'NickName', 'signon': '1720911069', 'timestamp': '1720911069', 'vhost': 'Clk-cloaked.address.ext', 'vident': 'Nickname'}

However I can't seem to find all of that information in an api call to nickserv info, and i realize this is a limitation of what nickserv returns from the ircd, and they have not written support to return the actual ip of the connected user, so I guess my question is, is there a command that I can pass to your api module that will return that same information? Im essentially trying to do a whois from an oper user via api calls, and I would use xmlrpc if it wasnt completely unauthenticated, which is the point of your module in the first place haha

Nickserv info code:```

url = http://127.0.0.1/api json = { "jsonrpc": "2.0", "id": 1, "method": "command", "service": "nickserv", "command": "info", "params": ["Nickname_here"], "ticket": { "ticket": token, "username": username, }, # include the authentication. }

response = requests.get(url, json=json).json()

if json.get("command") == "info": whois = str(response["return"]).splitlines()



api response list.
'Nickname is Nickname',
'      Account: Nickname', 
'  Online from: Nickname@sub.domain.tld', 
'  Online from: Nickname@Clk-cloak.domain.tld', 
'   Registered: Jul 13 21:36:08 2024 UTC (2 hours, 20 minutes ago)',
'Email address: any@email.com', 
'      Expires: Aug 03 23:56:18 2024 UTC (21 days from now)', 
'      Options: Private, Protection, Security, Auto-op'

Missing the IP sorta defeats the point of using the api vs xml_rpc, Hope you can help with any ideas.
ahopelesshadow commented 3 months ago

In the event that sadie doesnt switch to an api for 2.1.x do you intend to update this with 2.1.x support?

jnewing commented 2 months ago

In the event that sadie doesnt switch to an api for 2.1.x do you intend to update this with 2.1.x support?

Yes this is something I would like to do, and also get more involved with both Anope and Inspircd.

jnewing commented 1 month ago

when using the xmlrpc modules in anope, you can run the following via python:

import xmlrpc.client
anope_url = "http://127.0.0.1/xmlrpc"
xclient = xmlrpc.client.ServerProxy(anope_url)
whois = xclient.user("Username")

and the return would be similiar to the following dict. {'account': 'NickName', 'channels': 'whatever', 'chost': 'Cloak.xxxxx.hostmask.ext', 'host': 'sub.domain.ext', 'ident': 'NickName', 'ip': '127.0.0.1', 'nick': 'NickName', 'signon': '1720911069', 'timestamp': '1720911069', 'vhost': 'Clk-cloaked.address.ext', 'vident': 'Nickname'}

However I can't seem to find all of that information in an api call to nickserv info, and i realize this is a limitation of what nickserv returns from the ircd, and they have not written support to return the actual ip of the connected user, so I guess my question is, is there a command that I can pass to your api module that will return that same information? Im essentially trying to do a whois from an oper user via api calls, and I would use xmlrpc if it wasnt completely unauthenticated, which is the point of your module in the first place haha

Nickserv info code:```

url = http://127.0.0.1/api json = { "jsonrpc": "2.0", "id": 1, "method": "command", "service": "nickserv", "command": "info", "params": ["Nickname_here"], "ticket": { "ticket": token, "username": username, }, # include the authentication. }

response = requests.get(url, json=json).json()

if json.get("command") == "info": whois = str(response["return"]).splitlines()


api response list.
'Nickname is Nickname',
'      Account: Nickname', 
'  Online from: Nickname@sub.domain.tld', 
'  Online from: Nickname@Clk-cloak.domain.tld', 
'   Registered: Jul 13 21:36:08 2024 UTC (2 hours, 20 minutes ago)',
'Email address: any@email.com', 
'      Expires: Aug 03 23:56:18 2024 UTC (21 days from now)', 
'      Options: Private, Protection, Security, Auto-op'

Missing the IP sorta defeats the point of using the api vs xml_rpc, Hope you can help with any ideas.

So this was also a limited I created when I coded this module, it only allows the user to talk to services and not just execute any IRCd command. I've currently updated the module to work with Anope 2.1 and added a registration command allowing users effectively call the /ns register command. And would be open to changing DoCommand function to allow the end user to call anything they could on a normal IRC client. This would allow for commands like /whois etc...

ahopelesshadow commented 1 month ago

So this was also a limited I created when I coded this module, it only allows the user to talk to services and not just execute any IRCd command. I've currently updated the module to work with Anope 2.1 and added a registration command allowing users effectively call the /ns register command. And would be open to changing DoCommand function to allow the end user to call anything they could on a normal IRC client. This would allow for commands like /whois etc...

This is very helpful! I will check out your updated files, and start testing them in a scrap instance. I will let you know that I did do some mock testing a while ago, in combination with another 3pty module ns_saregister that allows a user to register another user for someone else (i had to make some changes to update that to 2.1 but it worked relatively easily) and that worked out perfectly with the prior version of your script.

As far as passing an irc command to pull the host ip, i ended up doing that with unreal json_rpc but as per my post above, the information is available to anope so long as the user requesting it is an oper, so i think it would be a useful addition to your module. I understand where you might have limited dev time or effort since sadie did say they were going to add auth to xmlrpc, but at the same time the json is a much better way to interact with everything. So I look forward to following changes to your project, if you need anyone to test anything, Id be happy to help out as well.