Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SVSCTRL command to let services control services join requests and configuration files #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kobishmueli
Copy link
Member

@kobishmueli kobishmueli commented Dec 12, 2018

To enable services join requests, services will send:
SVSCTRL server.dal.net SJR 1

To disable services join requests, services will send:
SVSCTRL server.dal.net SJR 0

(server.dal.net can be replaced by * to send it to all servers)

To get the list of supported configuration files, services will send:
SVSCTRL server.dal.net CONF STATUS *
The server will reply:

PRIVMSG <sender> :CONF STATUS <file1> <file-size> <modified-time> <md5-sha>
PRIVMSG <sender> :CONF STATUS <file2> <file-size> <modified-time> <md5-sha>
PRIVMSG <sender> :CONF STATUS <file3> <file-size> <modified-time> <md5-sha>

To get the status of ircd.conf, services will send:
SVSCTRL server.dal.net CONF STATUS ircd.conf
The server will reply:
PRIVMSG <sender> :CONF STATUS ircd.conf <file-size> <modified-time> <md5-sha>

To get the ircd.conf file from the server, services will send:
SVSCTRL server.dal.net CONF READ ircd.conf
The server will send:

PRIVMSG <sender> :CONF <file> SOF <file-size> <modified-time>
PRIVMSG <sender> :CONF <file> <line-number> :<line-text>
PRIVMSG <sender> :CONF <file> EOF <number-of-lines> <file-size> <md5-sha>

To update the ircd.conf file, services will send:

SVSCTRL server.dal.net CONF WRITE ircd.conf SOF
SVSCTRL server.dal.net CONF WRITE ircd.conf <line-number> :<line-text>
SVSCTRL server.dal.net CONF WRITE ircd.conf EOF <number-of-lines> <file-size> <md5-sha>

The server will reply:
PRIVMSG <sender> :CONF WRITE ircd.conf EOF OK
or:
PRIVMSG <sender> :CONF WRITE ircd.conf EOF ERROR :<reason>

-Kobi.

…d configuration files

To enable services join requests, services will send:
SVSCTRL server.dal.net SJR 1

To disable services join requests, services will send:
SVSCTRL server.dal.net SJR 0

(server.dal.net can be replaced by * to send it to all servers)

To get the list of supported configuration files, services will send:
SVSCTRL server.dal.net CONF STATUS *
The server will reply:
PRIVMSG <sender> :CONF STATUS <file1> <file-size> <modified-time> <md5-sha>
PRIVMSG <sender> :CONF STATUS <file2> <file-size> <modified-time> <md5-sha>
PRIVMSG <sender> :CONF STATUS <file3> <file-size> <modified-time> <md5-sha>

To get the status of ircd.conf, services will send:
SVSCTRL server.dal.net CONF STATUS ircd.conf
The server will reply:
PRIVMSG <sender> :CONF STATUS ircd.conf <file-size> <modified-time> <md5-sha>

To get the ircd.conf file from the server, services will send:
SVSCTRL server.dal.net CONF READ ircd.conf
The server will send:
PRIVMSG <sender> :CONF <file> SOF <file-size> <modified-time>
PRIVMSG <sender> :CONF <file> <line-number> :<line-text>
PRIVMSG <sender> :CONF <file> EOF <number-of-lines> <file-size> <md5-sha>

To update the ircd.conf file, services will send:
SVSCTRL server.dal.net CONF WRITE ircd.conf SOF
SVSCTRL server.dal.net CONF WRITE ircd.conf <line-number> :<line-text>
SVSCTRL server.dal.net CONF WRITE ircd.conf EOF <number-of-lines> <file-size> <md5-sha>
The server will reply:
PRIVMSG <sender> :CONF WRITE ircd.conf EOF OK
or:
PRIVMSG <sender> :CONF WRITE ircd.conf EOF ERROR :<reason>

-Kobi.
@eaescob
Copy link
Contributor

eaescob commented Dec 14, 2018

Interesting. Lots to digest here. How has testing gone for this?

@kobishmueli
Copy link
Member Author

      Interesting. Lots to digest here. How has testing gone for this?

I did a few quick sanity checks on the testnet for it, i.e.:

  1. Get a file status: :OperServ SVSCTRL test1.* CONF STATUS /etc/rc.conf
  2. Get the status of all files: :OperServ SVSCTRL hideout.* CONF STATUS *
  3. Write a test conf file:
:OperServ SVSCTRL test1.* CONF WRITE dalnet.conf SOF
:OperServ SVSCTRL test1.* CONF WRITE dalnet.conf 1 :This is a test...
:OperServ SVSCTRL test1.* CONF WRITE dalnet.conf EOF 1 18 c56c8063d58e9bc9b3fb0dc03fe531b0
  1. Read a file: :OperServ SVSCTRL test1.* CONF READ /etc/rc.conf
  2. Tried to break ircd.conf to make sure it reverts the previous config back.

It looks fine but I will do more tests once stats.* will support it :)

-Kobi.

@eaescob
Copy link
Contributor

eaescob commented Dec 19, 2018

Great! I will hold off merging until you have

@eaescob
Copy link
Contributor

eaescob commented May 4, 2019

Is this still needed?

@kobishmueli
Copy link
Member Author

Is this still needed?

Yes, I reviewed it again and did a few more sanity checks and it looks fine.

-Kobi.

Comment on lines +1311 to +1319
sendto_one(sptr, ":%s PRIVMSG %s :CONF %s SOF %ld %ld", me.name, parv[0], fn, sb.st_size, sb.st_mtime);
while(fgets(line, BUFSIZE, f) != NULL)
{
while((tmp = strchr(line,'\r'))) *tmp = '\0';
while((tmp = strchr(line,'\n'))) *tmp = '\0';
line_counter++;
sendto_one(sptr, ":%s PRIVMSG %s :CONF %s %d :%s", me.name, parv[0], fn, line_counter, line);
}
sendto_one(sptr, ":%s PRIVMSG %s :CONF %s EOF %d %ld %s", me.name, parv[0], fn, line_counter, sb.st_size, md5file(fn));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all of the replies for reading should have the "READ" parameter before the file name to be consistent with the rest of the system

:%s PRIVMSG %s :CONF READ %s SOF %ld %d instead of :%s PRIVMSG %s :CONF %s SOF %ld %ld

The same for the line replies and the EOF reply.

@eaescob
Copy link
Contributor

eaescob commented May 15, 2020

Some conflicts that need to be resolved, can you please check?

@github-actions
Copy link

Stale pull request message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants