blob: eac33195caa662435b268cc6d6295eec1073ab85 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "rpcserviceaddress.h"
namespace mbus {
RPCServiceAddress::RPCServiceAddress(const string &serviceName,
const string &connectionSpec) :
_serviceName(serviceName),
_sessionName(""),
_connectionSpec(connectionSpec),
_target()
{
size_t pos = serviceName.find_last_of('/');
if (pos != string::npos) {
_sessionName = serviceName.substr(pos + 1);
}
}
RPCServiceAddress::~RPCServiceAddress() {}
bool
RPCServiceAddress::isMalformed()
{
if (_serviceName.empty()) {
return true; // no service
}
if (_sessionName.empty()) {
return true; // no session
}
if (_connectionSpec.empty()) {
return true; // no spec
}
size_t prefixPos = _connectionSpec.find("tcp/");
if (prefixPos != 0) {
return true; // no prefix
}
size_t portPos = _connectionSpec.find_first_of(':', prefixPos);
if (portPos == string::npos) {
return true; // not colon
}
if (portPos == prefixPos + 4) {
return true; // no address
}
if (portPos == _connectionSpec.size() - 1) {
return true; // no port
}
return false;
}
} // namespace mbus
|