示例#1
0
6. The router has a filter/mangle/nat rule that overrides the settings at
   "/ip service".
   This is a very rare scenario, but if you want to be sure, try to disable all
   rules that may cause such a thing, or (if you can afford it) set up a fresh
   RouterOS in place of the existing one, and see if you can connect to it
   instead. If you still can't connect, such a rule is certainly not the (only)
   reason.

HEREDOC
);
    }
    return;
}
if (null !== $cmd->args['username']) {
    try {
        if (!RouterOS\Client::login($com, $cmd->args['username'], (string) $cmd->args['password'], $comTimeout)) {
            fwrite(STDERR, <<<HEREDOC
Login refused. Possible reasons:

1. No such username.
   Make sure you have spelled it correctly.

2. The user does not have the "api" privilege.
   Check the permissions of the user's group at "/user group".

3. The user is not allowed to access the router from your web server's IP.
   Make sure your web server's IP address is within the subnets the user is
   allowed to log in from. You can check them at the "address" property
   of the user in the "/user" menu.

4. Mistyped password.
 public function testTaglessModePassing()
 {
     $com1 = new Communicator(\HOSTNAME, PORT, true);
     Client::login($com1, USERNAME, PASSWORD);
     $reg1 = new Registry('dummy');
     $com2 = new Communicator(\HOSTNAME, PORT, true);
     $reg2 = new Registry('dummy');
     $this->assertNotEquals($reg1->getOwnershipTag(), $reg2->getOwnershipTag());
     $pingRequest1 = new Request('/ping address=' . HOSTNAME, null, 'ping');
     $pingRequest1->send($com1, $reg1);
     $response1_1 = new Response($com1, false, null, null, $reg1);
     $cancelRequest = new Request('/cancel');
     $reg1->setTaglessMode(true);
     $cancelRequest->setArgument('tag', $reg1->getOwnershipTag() . 'ping');
     $cancelRequest->send($com1, $reg1);
     $pingRequest2 = new Request('/ping count=2 address=' . HOSTNAME, null, 'ping');
     $pingRequest2->send($com2, $reg2);
     $response2_1 = new Response($com2, false, null, null, $reg2);
     $response2_2 = new Response($com2, false, null, null, $reg2);
     $response2_3 = new Response($com2, false, null, null, $reg2);
     $reg1->setTaglessMode(false);
     $com1->close();
     $com2->close();
     $this->assertEquals(Response::TYPE_DATA, $response2_1->getType());
     $this->assertEquals(Response::TYPE_DATA, $response2_2->getType());
     $this->assertEquals(Response::TYPE_FINAL, $response2_3->getType());
     $response1_2 = new Response($com1, false, null, null, $reg1);
     $response1_3 = new Response($com1, false, null, null, $reg1);
     $this->assertEquals(Response::TYPE_DATA, $response1_1->getType());
     $this->assertEquals(Response::TYPE_ERROR, $response1_2->getType());
     $this->assertEquals(Response::TYPE_FINAL, $response1_3->getType());
     $reg1->close();
     $this->assertStringStartsWith('-1_', $reg2->getOwnershipTag());
 }
 public function testInvalidQuerySending()
 {
     $com = new Communicator(\HOSTNAME, PORT);
     Client::login($com, USERNAME, PASSWORD);
     $com->sendWord('/ip/arp/print');
     $com->close();
     try {
         Query::where('address', HOSTNAME_INVALID)->send($com);
         $com->sendWord('');
         $this->fail('The query had to fail.');
     } catch (SocketException $e) {
         $this->assertEquals(SocketException::CODE_QUERY_SEND_FAIL, $e->getCode(), 'Improper exception code.');
     }
 }