You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the minimum configuration required to enable the feature:
491
+
This example configuration adds some restrictions (only requests from localhost are accepted, the XML-RPC query must include authentication credentials of a specific account registered in ejabberd, and only two commands are accepted):
492
+
493
+
```yaml
494
+
listen:
495
+
-
496
+
port: 5280
497
+
ip: "::"
498
+
module: ejabberd_http
499
+
request_handlers:
500
+
/xmlrpc: ejabberd_xmlrpc
501
+
502
+
api_permissions:
503
+
"some XMLRPC commands":
504
+
from: ejabberd_xmlrpc
505
+
who:
506
+
- ip: 127.0.0.1
507
+
- user: user1@localhost
508
+
what:
509
+
- registered_users
510
+
- connected_users_number
511
+
```
512
+
513
+
Example Python3 script for that restricted configuration:
514
+
515
+
```python
516
+
import xmlrpc.client
517
+
server = xmlrpc.client.ServerProxy("http://127.0.0.1:5280/xmlrpc/");
518
+
519
+
params = {}
520
+
params['host'] = 'localhost'
521
+
522
+
auth = {'user': 'user1',
523
+
'server': 'localhost',
524
+
'password': 'mypass11',
525
+
'admin': True}
526
+
527
+
def calling(command, data):
528
+
fn = getattr(server, command)
529
+
return fn(auth, data)
530
+
531
+
print(calling('registered_users', params))
532
+
```
533
+
534
+
Please notice, when using the old Python2, replace the two first lines with:
466
535
467
-
listen:
468
-
-
469
-
port: 4560
470
-
module: ejabberd_http
471
-
request_handlers:
472
-
/: ejabberd_xmlrpc
473
-
474
-
Example Python script:
475
-
476
-
import xmlrpclib
477
-
server = xmlrpclib.Server('http://127.0.0.1:4560/');
478
-
params = {}
479
-
params["host"] = "localhost"
480
-
print server.registered_users(params)
481
-
482
-
This example configuration adds some restrictions:
483
-
484
-
listen:
485
-
-
486
-
port: 5281
487
-
ip: "::"
488
-
module: ejabberd_http
489
-
request_handlers:
490
-
/api: mod_http_api
491
-
/xmlrpc: ejabberd_xmlrpc
492
-
493
-
api_permissions:
494
-
"some XMLRPC commands":
495
-
from: ejabberd_xmlrpc
496
-
who:
497
-
- ip: 127.0.0.1
498
-
- user: user1@localhost
499
-
what:
500
-
- registered_users
501
-
- connected_users_number
502
-
503
-
With that configuration, it is possible to execute two specific commands using
504
-
`ejabberd_xmlrpc`, with two access restrictions. Example Python script:
505
-
506
-
import xmlrpclib
507
-
server = xmlrpclib.Server('http://127.0.0.1:5281/xmlrpc')
0 commit comments