]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/log
irc/unrealircd/unrealircd-rpc-php.git
12 months agoReturn from $rpc->eventloop() after 2 seconds instead of 10. main origin/HEAD origin/main
Bram Matthys [Mon, 8 May 2023 06:27:26 +0000 (08:27 +0200)] 
Return from $rpc->eventloop() after 2 seconds instead of 10.
This so keepalive-like packets can be sent to the browser by the webpanel
every 2 seconds instead of 10 seconds (for better explanation see webpanel)

12 months ago$rpc->log()->getAll() now has a $sources argument which allows you
Bram Matthys [Fri, 5 May 2023 13:11:38 +0000 (15:11 +0200)] 
$rpc->log()->getAll() now has a $sources argument which allows you
to filter on existing events. Uses same sources as ->subscribe().

12 months agoWhoops.. i was wrong.. microtime() w/$as_float=true... duh :D
Bram Matthys [Thu, 27 Apr 2023 18:42:21 +0000 (20:42 +0200)] 
Whoops.. i was wrong.. microtime() w/$as_float=true... duh :D

12 months agoThis fix-for-endless-exception used <1ms while it should use <1s.
Bram Matthys [Thu, 27 Apr 2023 18:36:09 +0000 (20:36 +0200)] 
This fix-for-endless-exception used <1ms while it should use <1s.
Also, I wonder if the fix is still needed as i (accidentally)
updated the websocket library today.

I'm getting:
PHP Fatal error:  Uncaught WebSocket\\TimeoutException: Client read timeout in
..etc..

12 months agoFix wrong function arguments (well, will be changed at some point)
Bram Matthys [Thu, 27 Apr 2023 18:34:31 +0000 (20:34 +0200)] 
Fix wrong function arguments (well, will be changed at some point)

12 months agoActually return ->list...
Bram Matthys [Thu, 27 Apr 2023 18:16:54 +0000 (20:16 +0200)] 
Actually return ->list...

12 months agoAdd log.list (yeah that is in progress :D)
Bram Matthys [Thu, 27 Apr 2023 18:10:13 +0000 (20:10 +0200)] 
Add log.list (yeah that is in progress :D)

12 months agoquery(): handle replies for different id, for errors too. Fixes 6.0.7 issue
Bram Matthys [Thu, 27 Apr 2023 18:04:49 +0000 (20:04 +0200)] 
query(): handle replies for different id, for errors too. Fixes 6.0.7 issue
due to recent change with set_issuer (as this method did not exist in
UnrealIRCd version 6.0.7 it would cause an error later on).

12 months agoUpdate composer dependencies. End users need to run 'composer install'.
Bram Matthys [Thu, 27 Apr 2023 12:42:49 +0000 (14:42 +0200)] 
Update composer dependencies. End users need to run 'composer install'.
This so 02da13a9d49686e9a6c6254c7318e3e145debbf3 actually works
(set "issuer" in UnrealIRCd\Connection options to save 1 round trip).

Note: if end-user forgets to call 'composer install' then this means
set by is not logged now.

12 months agoMake query() throw an error when the request timed out (defined as >10sec).
Bram Matthys [Thu, 27 Apr 2023 11:44:37 +0000 (13:44 +0200)] 
Make query() throw an error when the request timed out (defined as >10sec).

12 months agoOn new connection, call rpc.set_issuer but don't wait for the reply.
Bram Matthys [Thu, 27 Apr 2023 11:40:38 +0000 (13:40 +0200)] 
On new connection, call rpc.set_issuer but don't wait for the reply.
This to speed up connection time a bit.

Related changes:
* query() now has an extra argument $no_wait which defaults to false
  (and is set to true for rpc.set_issuer call if $options["issuer"]
  is set in new UnrealIRCd\Connection.
* query() now waits for the reply for the correct id.

12 months agoAllow setting "issuer" in UnrealIRCd\Connection options to save 1 round trip.
Bram Matthys [Thu, 27 Apr 2023 07:29:33 +0000 (09:29 +0200)] 
Allow setting "issuer" in UnrealIRCd\Connection options to save 1 round trip.
Without it, we will still do a ping-pong to force the connection.
With issuer, we don't need that ping-pong.

12 months agoAdd $rpc->rpc()->add_timer(); and ->del_timer()
Bram Matthys [Wed, 12 Apr 2023 08:48:27 +0000 (10:48 +0200)] 
Add $rpc->rpc()->add_timer(); and ->del_timer()

Add a timer. Requires UnrealIRCd 6.1.0+
@param timer_id         Name of the timer (so you can .del_timer later)
@param every_msec       Every -this- milliseconds the command must be executed
@param method           The JSON-RPC method to execute (lowlevel name, eg "stats.get")
@param params           Parameters to the JSON-RPC call that will be executed, can be NULL
@param id               Set JSON-RPC id to be used in the timer, leave NULL for auto id.
@return stdClass|array|bool

Example usage would be:
$rpc->rpc()->add_timer("timer", 1000, "stats.get");

12 months agoActually return something ;)
Bram Matthys [Wed, 12 Apr 2023 06:35:50 +0000 (08:35 +0200)] 
Actually return something ;)

12 months agoAdd $rpc->stats()->get();
Bram Matthys [Wed, 12 Apr 2023 06:31:52 +0000 (08:31 +0200)] 
Add $rpc->stats()->get();

13 months agoWorkaround library bug in eventloop(). Apparently if there is little
Bram Matthys [Mon, 10 Apr 2023 15:56:19 +0000 (17:56 +0200)] 
Workaround library bug in eventloop(). Apparently if there is little
activity and we catch the timeout once and we continue, then if there
is some other error like server killed or otherwise connection lost
then it will refire as a timeout, and this happens endlessly, so
resulting in 100% CPU loop.
We now detect it by (far) too little execution time, ah well, it is
a workaround that works :D.

So this should be safe now (was introduced a previous commit,
still the same code):

$rpc->log()->subscribe(Array("!debug","all"));
while(1)
{
    echo "Waiting...\n";
    $res = $rpc->eventloop();
    var_export($res);
    echo "\n";
}

13 months agoAdd streaming JSON-LOG support. Requires UnrealIRCd 6.1.0+
Bram Matthys [Sat, 8 Apr 2023 16:42:51 +0000 (18:42 +0200)] 
Add streaming JSON-LOG support. Requires UnrealIRCd 6.1.0+
(post-rc1 git)

Example:

$rpc->log()->subscribe(Array("!debug","all"));
while(1)
{
    echo "Waiting...\n";
    $res = $rpc->eventloop();
    var_export($res);
    echo "\n";
}

$rpc->eventloop() will return NULL if there is no activity
for 10 seconds, so it is not entirely blocking. You can safely
re-run $rpc->eventloop(); if return value === NULL.

13 months agoAdd $conn->rpc->info() and $conn->rpc->set_issuer("NameOfLoggedInUser")
Bram Matthys [Fri, 31 Mar 2023 11:56:40 +0000 (13:56 +0200)] 
Add $conn->rpc->info() and $conn->rpc->set_issuer("NameOfLoggedInUser")
The latter requires UnrealIRCd 6.0.8+

13 months agoUser: add optional $object_detail_level argument to getAll() and get().
Bram Matthys [Mon, 27 Mar 2023 11:31:11 +0000 (13:31 +0200)] 
User: add optional $object_detail_level argument to getAll() and get().
Similar to Channel getAll() and get() this specifies the amount of
detail that a server will return, see "Structure of a client object"
at https://www.unrealircd.org/docs/JSON-RPC:User

Only works in UnrealIRCd 6.0.8 or later, simply ignored in earlier versions.

If you only need a minimal amount of information, consider using a
lower object_detail_level. It saves both CPU and bandwidth.

In UnrealIRCd 6.0.8+ the user.get call returns the same information with
the default object_detail_level as in 6.0.7.

For the user.list call, UnrealIRCd 6.0.8 has a "breaking change":
the "channels" of the user are no longer returned with the default
object_detail_level value of 2. If you require that information, then
set object_detail_level to 4, like: $rpc->user()->getAll(4);

13 months agoPermit Server->get() to get the current server settings.
Bram Matthys [Mon, 27 Mar 2023 08:42:38 +0000 (10:42 +0200)] 
Permit Server->get() to get the current server settings.
UnrealIRCd already supports this since 6.0.5 or 6.0.6.

13 months agoChannel: add optional $object_detail_level argument to getAll() and get().
Bram Matthys [Mon, 27 Mar 2023 08:31:04 +0000 (10:31 +0200)] 
Channel: add optional $object_detail_level argument to getAll() and get().
This decides the amount of detail that is returned, see under
"Structure of a channel" at https://www.unrealircd.org/docs/JSON-RPC:Channel

Only works in UnrealIRCd 6.0.8 or later, simply ignored in earlier versions.

13 months agoMore README updates.
Bram Matthys [Sat, 25 Mar 2023 18:12:50 +0000 (19:12 +0100)] 
More README updates.

13 months agoSome more README updates
Bram Matthys [Sat, 25 Mar 2023 18:10:41 +0000 (19:10 +0100)] 
Some more README updates

13 months agoUpdate the README a bit now that things have settled.
Bram Matthys [Sat, 25 Mar 2023 18:07:58 +0000 (19:07 +0100)] 
Update the README a bit now that things have settled.

13 months agoUpdate Channel.php
Valerie Pond [Thu, 23 Mar 2023 21:03:04 +0000 (21:03 +0000)] 
Update Channel.php

Fix incorrect method.

15 months agoStart the JSON-RPC connection immediately, so connection errors also happen
Bram Matthys [Sat, 14 Jan 2023 16:18:19 +0000 (17:18 +0100)] 
Start the JSON-RPC connection immediately, so connection errors also happen
immediately during the call new UnrealIRCd\Connection(.....)

15 months agoserver->disconnect() include reason
Valerie Pond [Sat, 14 Jan 2023 07:08:42 +0000 (07:08 +0000)] 
server->disconnect() include reason

15 months agoFix possible crash cause
Valerie Pond [Sat, 14 Jan 2023 00:58:53 +0000 (00:58 +0000)] 
Fix possible crash cause

15 months agoserver.module_list Allow specifying a server name name
Valerie Pond [Fri, 13 Jan 2023 22:18:33 +0000 (22:18 +0000)] 
server.module_list Allow specifying a server name name

15 months agoAdd $rpc->server()->module_list() - only for local server atm
Bram Matthys [Fri, 13 Jan 2023 08:43:25 +0000 (09:43 +0100)] 
Add $rpc->server()->module_list() - only for local server atm

15 months agoUpdate composer.lock
Valerie Pond [Thu, 12 Jan 2023 21:54:13 +0000 (21:54 +0000)] 
Update composer.lock

15 months ago-sigh- fix for previous
Bram Matthys [Thu, 12 Jan 2023 16:32:36 +0000 (17:32 +0100)] 
-sigh- fix for previous

15 months agoBanException -> ServerBanException and
Bram Matthys [Thu, 12 Jan 2023 16:30:38 +0000 (17:30 +0100)] 
BanException -> ServerBanException and
$rpc->exceptikon() -> $rpc->serverbanexception()

15 months agoAdd BanException class
Valerie Pond [Wed, 11 Jan 2023 22:23:31 +0000 (22:23 +0000)] 
Add BanException class

15 months agoAdd Server class for interacting with servers
Valerie Pond [Wed, 11 Jan 2023 21:47:34 +0000 (21:47 +0000)] 
Add Server class for interacting with servers

15 months agoUpdate some apidoc and remove throw on user not found.
Bram Matthys [Wed, 11 Jan 2023 06:45:11 +0000 (07:45 +0100)] 
Update some apidoc and remove throw on user not found.
(yeah this whole thing needs an overhaul, later.. later..)

15 months agoActually fix some return errors mentioned in previous commit
Valerie Pond [Tue, 10 Jan 2023 05:14:00 +0000 (05:14 +0000)] 
Actually fix some return errors mentioned in previous commit

15 months agoAdd nameban to Connection.php and various bugfixes
Valerie Pond [Tue, 10 Jan 2023 05:08:49 +0000 (05:08 +0000)] 
Add nameban to Connection.php and various bugfixes

In many cases on a failed lookup such as if a nick didn't exist, this threw an exception which halted things. Also in some cases there weren't bool checks when there needed to be for such catches

16 months agoMake the *.get/*.add/*.delete calls return the channel/user/.. directly.
Bram Matthys [Mon, 9 Jan 2023 12:02:15 +0000 (13:02 +0100)] 
Make the *.get/*.add/*.delete calls return the channel/user/.. directly.
So:
$user = $rpc->user()->get("Syzop");
if ($user->client->name == "Syzop")
..
Becomes:
$user = $rpc->user()->get("Syzop");
if ($user->name == "Syzop")
..

And:
$spamfilter = $rpc->spamfilter()->add(...etc...)
Then not dump $spamfilter->tkl but simply $spamfilter.

Makes more sense, I think.

16 months agoCreate NameBan class for adding QLines
Valerie Pond [Mon, 9 Jan 2023 03:30:54 +0000 (03:30 +0000)] 
Create NameBan class for adding QLines

16 months agoAdd all the new RPC calls in 6.0.6-git at the moment:
Bram Matthys [Sat, 7 Jan 2023 18:42:05 +0000 (19:42 +0100)] 
Add all the new RPC calls in 6.0.6-git at the moment:

== channel ==
public function set_mode(string $channel, string $modes, string $parameters): stdClass|array|bool
public function set_topic(string $channel, string $topic,
                          string $set_by=null, string $set_at=null): stdClass|array|bool
public function kick(string $channel, string $nick, string $reason): stdClass|array|bool
See also https://www.unrealircd.org/docs/JSON-RPC:Channel

== user ==
public function set_nick(string $nick, string $newnick): stdClass|array|bool
public function set_username(string $nick, string $username): stdClass|array|bool
public function set_realname(string $nick, string $realname): stdClass|array|bool
public function set_vhost(string $nick, string $vhost): stdClass|array|bool
public function set_mode(string $nick, string $mode, bool $hidden = false): stdClass|array|bool
public function set_snomask(string $nick, string $snomask, bool $hidden = false): stdClass|array|bool
public function set_oper(string $nick, string $oper_account, string $oper_class,
                         string $class = null, string $modes = null,
                         string $snomask = null, string $vhost = null): stdClass|array|bool
public function join(string $nick, string $channel,
                     string $key = null, bool $force = false): stdClass|array|bool
public function part(string $nick, string $channel, bool $force = false): stdClass|array|bool
public function quit(string $nick, string $reason): stdClass|array|bool
public function kill(string $nick, string $reason): stdClass|array|bool
See also https://www.unrealircd.org/docs/JSON-RPC:User

16 months agoMake getAll() return the list of users without wrapping it under a 'list' item.
Bram Matthys [Fri, 6 Jan 2023 19:23:59 +0000 (20:23 +0100)] 
Make getAll() return the list of users without wrapping it under a 'list' item.

So:

     $bans = $rpc->serverban()->getAll();
-    foreach ($bans->list as $ban)
+    foreach ($bans as $ban)
         echo "There's a $ban->type on $ban->name\n";

     $users = $rpc->user()->getAll();
-    foreach ($users->list as $user)
+    foreach ($users as $user)
         echo "User $user->name\n";

     $channels = $rpc->channel()->getAll();
-    foreach ($channels->list as $channel)
+    foreach ($channels as $channel)
         echo "Channel $channel->name ($channel->num_users user[s])\n";

16 months agoAll functions now return FALSE on failure, and then errno and error can
Bram Matthys [Fri, 6 Jan 2023 19:18:46 +0000 (20:18 +0100)] 
All functions now return FALSE on failure, and then errno and error can
be checked, like:

if ($rpc->serverban()->add($user, $bantype, $duration, $reason))
    echo "SUCCESS\n";
else
    echo "FAILURE: $rpc->error ($rpc->errno)\n";

16 months agoAdd Spamfilter support
Bram Matthys [Fri, 6 Jan 2023 18:47:33 +0000 (19:47 +0100)] 
Add Spamfilter support

16 months agoAdd a small warning too :D
Bram Matthys [Fri, 6 Jan 2023 17:27:44 +0000 (18:27 +0100)] 
Add a small warning too :D

16 months agoUpdate README.
Bram Matthys [Fri, 6 Jan 2023 17:24:05 +0000 (18:24 +0100)] 
Update README.

16 months agoActually require PHP8 again, since our dependencies do too.
Bram Matthys [Fri, 6 Jan 2023 15:58:02 +0000 (16:58 +0100)] 
Actually require PHP8 again, since our dependencies do too.

16 months agoDrop PHP8 requirement (testing testing :D)
Bram Matthys [Fri, 6 Jan 2023 14:48:36 +0000 (15:48 +0100)] 
Drop PHP8 requirement (testing testing :D)

16 months agoSame as previous, explicit args, but for ServerBan and Channel
Bram Matthys [Fri, 6 Jan 2023 14:31:26 +0000 (15:31 +0100)] 
Same as previous, explicit args, but for ServerBan and Channel

16 months agoGet rid of PHP Contracts
Bram Matthys [Fri, 6 Jan 2023 14:28:50 +0000 (15:28 +0100)] 
Get rid of PHP Contracts

16 months agoDon't use arrays in parameters but use explicit options everwhere.
Bram Matthys [Fri, 6 Jan 2023 14:24:17 +0000 (15:24 +0100)] 
Don't use arrays in parameters but use explicit options everwhere.
For example in ServerBan, from:
public function add(string $user, array $params): stdClass;
To:
public function add(string $name, string $type, string $duration, string $reason): stdClass;

As the whole point of having these PHP functions is that it is immediately
transparent which things you need to pass.

16 months agoBan -> ServerBan part II
Bram Matthys [Fri, 6 Jan 2023 14:10:38 +0000 (15:10 +0100)] 
Ban -> ServerBan part II

16 months agoBan -> ServerBan
Bram Matthys [Fri, 6 Jan 2023 14:09:46 +0000 (15:09 +0100)] 
Ban -> ServerBan

16 months agoMajor API break:
Bram Matthys [Fri, 6 Jan 2023 14:06:13 +0000 (15:06 +0100)] 
Major API break:
* Change all the ->get() to ->getAll()
  and all the ->show() to ->get()
  .. eg for User, Channel, etc.
* You now only create an API connection once, as it was always
  intended:
  $rpc = new UnrealIRCd\Connection(..)
* You can then either use the non-connection classes like this:
  $user = new User($rpc);
  $result = $user->getAll();
  Or simply use this style:
  $result = $rpc->user()->getAll();
* More breakage to come

20 months agoReplace a stray "response" prop with "result"
Denver F [Mon, 5 Sep 2022 15:52:23 +0000 (16:52 +0100)] 
Replace a stray "response" prop with "result"

20 months agoMerge pull request #6 from unrealircd/wip
Denver F [Sun, 21 Aug 2022 19:07:28 +0000 (20:07 +0100)] 
Merge pull request #6 from unrealircd/wip

Accidentally checked for "reply" prop instead of "result"

20 months agoAccidentally checked for "reply" prop instead of "result"
Denver F [Sun, 21 Aug 2022 19:07:13 +0000 (20:07 +0100)] 
Accidentally checked for "reply" prop instead of "result"

20 months agoMerge pull request #5 from unrealircd/wip
Denver F [Wed, 17 Aug 2022 15:36:47 +0000 (16:36 +0100)] 
Merge pull request #5 from unrealircd/wip

Wip

20 months agoAdded version to composer.json and a couple of small (hopefully non-breaking) changes
Denver F [Wed, 17 Aug 2022 15:35:25 +0000 (16:35 +0100)] 
Added version to composer.json and a couple of small (hopefully non-breaking) changes

20 months agoUpdate Connection::query to listen for a "reply" response rather than "response"...
Denver F [Wed, 17 Aug 2022 15:29:13 +0000 (16:29 +0100)] 
Update Connection::query to listen for a "reply" response rather than "response" from the rpc server.

22 months agoThis brings this branch up-to-date with the changes I made to the package in the...
Denver F [Sun, 10 Jul 2022 06:20:36 +0000 (07:20 +0100)] 
This brings this branch up-to-date with the changes I made to the package in the webpanel project.

22 months agoUse the correct parameter for gline expiry timestamp
Denver F [Sun, 10 Jul 2022 01:08:00 +0000 (02:08 +0100)] 
Use the correct parameter for gline expiry timestamp

22 months agoReturn errors from the ircd
Denver F [Sun, 10 Jul 2022 01:02:58 +0000 (02:02 +0100)] 
Return errors from the ircd

22 months agoMerge pull request #4 from unrealircd/wip
Denver F [Mon, 4 Jul 2022 18:34:01 +0000 (19:34 +0100)] 
Merge pull request #4 from unrealircd/wip

Wip

22 months agoThis should be everything working now.
Denver F [Mon, 4 Jul 2022 18:33:30 +0000 (19:33 +0100)] 
This should be everything working now.

22 months agoReturn types :<
Denver F [Mon, 4 Jul 2022 18:28:19 +0000 (19:28 +0100)] 
Return types :<

22 months agoReturn types again
Denver F [Mon, 4 Jul 2022 18:23:30 +0000 (19:23 +0100)] 
Return types again

22 months agoUpdate PHP version requirement
Denver F [Mon, 4 Jul 2022 18:22:09 +0000 (19:22 +0100)] 
Update PHP version requirement

22 months agoMore fixes on return types
Denver F [Mon, 4 Jul 2022 18:21:10 +0000 (19:21 +0100)] 
More fixes on return types

22 months agoMerge pull request #3 from unrealircd/wip
Denver F [Mon, 4 Jul 2022 18:18:27 +0000 (19:18 +0100)] 
Merge pull request #3 from unrealircd/wip

Fix querying the response object for ID when its not part of that obj…

22 months agoFix querying the response object for ID when its not part of that object.
Denver F [Mon, 4 Jul 2022 18:16:54 +0000 (19:16 +0100)] 
Fix querying the response object for ID when its not part of that object.
Remove useless code in Channel

22 months agoMerge pull request #2 from unrealircd/wip
Denver F [Mon, 4 Jul 2022 18:15:33 +0000 (19:15 +0100)] 
Merge pull request #2 from unrealircd/wip

Wip

22 months agoRemove $id from UnrealIRCd\Channel
Denver F [Mon, 4 Jul 2022 18:14:47 +0000 (19:14 +0100)] 
Remove $id from UnrealIRCd\Channel

22 months agoChange return types to \stdClass.
Denver F [Mon, 4 Jul 2022 18:14:08 +0000 (19:14 +0100)] 
Change return types to \stdClass.

22 months agoAllow any php8 version
Denver F [Mon, 4 Jul 2022 17:54:29 +0000 (18:54 +0100)] 
Allow any php8 version

22 months agoMerge pull request #1 from unrealircd/wip
Denver F [Mon, 4 Jul 2022 17:52:38 +0000 (18:52 +0100)] 
Merge pull request #1 from unrealircd/wip

Wip

22 months agoThis should be enough for some preliminary usage.
Denver F [Mon, 4 Jul 2022 17:42:56 +0000 (18:42 +0100)] 
This should be enough for some preliminary usage.

22 months agoWIP
Denver F [Sat, 2 Jul 2022 16:05:55 +0000 (17:05 +0100)] 
WIP

22 months agoUpdate installation example, use :dev-main for now.
Bram Matthys [Sun, 26 Jun 2022 15:29:58 +0000 (17:29 +0200)] 
Update installation example, use :dev-main for now.

22 months agoUpdate README
Bram Matthys [Sun, 26 Jun 2022 15:17:15 +0000 (17:17 +0200)] 
Update README

22 months agoImport of initial proof-of-concept
Bram Matthys [Sun, 26 Jun 2022 14:58:46 +0000 (16:58 +0200)] 
Import of initial proof-of-concept

22 months agoInitial commit
Bram Matthys [Sun, 26 Jun 2022 14:54:53 +0000 (14:54 +0000)] 
Initial commit