Skip to content

Commit

Permalink
Merge pull request apache#1139 from TousakaRin/use_443_as_default_por…
Browse files Browse the repository at this point in the history
…t_for_https

For https naming service, use 443 as default port
  • Loading branch information
jamesge authored Sep 10, 2020
2 parents 7bda11b + fdb4e77 commit 71aa40c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/brpc/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ const char* const DUMMY_SERVER_PORT_FILE = "dummy_server.port";

struct GlobalExtensions {
GlobalExtensions()
: ch_mh_lb(CONS_HASH_LB_MURMUR3)
: dns(80)
, dns_with_ssl(443)
, ch_mh_lb(CONS_HASH_LB_MURMUR3)
, ch_md5_lb(CONS_HASH_LB_MD5)
, ch_ketama_lb(CONS_HASH_LB_KETAMA)
, constant_cl(0) {
Expand All @@ -127,6 +129,7 @@ struct GlobalExtensions {
FileNamingService fns;
ListNamingService lns;
DomainNamingService dns;
DomainNamingService dns_with_ssl;
RemoteFileNamingService rfns;
ConsulNamingService cns;
DiscoveryNamingService dcns;
Expand Down Expand Up @@ -346,7 +349,7 @@ static void GlobalInitializeOrDieImpl() {
NamingServiceExtension()->RegisterOrDie("file", &g_ext->fns);
NamingServiceExtension()->RegisterOrDie("list", &g_ext->lns);
NamingServiceExtension()->RegisterOrDie("http", &g_ext->dns);
NamingServiceExtension()->RegisterOrDie("https", &g_ext->dns);
NamingServiceExtension()->RegisterOrDie("https", &g_ext->dns_with_ssl);
NamingServiceExtension()->RegisterOrDie("redis", &g_ext->dns);
NamingServiceExtension()->RegisterOrDie("remotefile", &g_ext->rfns);
NamingServiceExtension()->RegisterOrDie("consul", &g_ext->cns);
Expand Down
8 changes: 5 additions & 3 deletions src/brpc/policy/domain_naming_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
namespace brpc {
namespace policy {

DomainNamingService::DomainNamingService() : _aux_buf_len(0) {}
DomainNamingService::DomainNamingService(int default_port)
: _aux_buf_len(0)
, _default_port(default_port) {}

int DomainNamingService::GetServers(const char* dns_name,
std::vector<ServerNode>* servers) {
Expand All @@ -51,7 +53,7 @@ int DomainNamingService::GetServers(const char* dns_name,
}

buf[i] = '\0';
int port = 80; // default port of HTTP
int port = _default_port;
if (dns_name[i] == ':') {
++i;
char* end = NULL;
Expand Down Expand Up @@ -142,7 +144,7 @@ void DomainNamingService::Describe(
}

NamingService* DomainNamingService::New() const {
return new DomainNamingService;
return new DomainNamingService(_default_port);
}

void DomainNamingService::Destroy() {
Expand Down
4 changes: 3 additions & 1 deletion src/brpc/policy/domain_naming_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ namespace policy {

class DomainNamingService : public PeriodicNamingService {
public:
DomainNamingService();
DomainNamingService(int default_port);
DomainNamingService() : DomainNamingService(80) {}

private:
int GetServers(const char *service_name,
Expand All @@ -43,6 +44,7 @@ class DomainNamingService : public PeriodicNamingService {
private:
std::unique_ptr<char[]> _aux_buf;
size_t _aux_buf_len;
int _default_port;
};

} // namespace policy
Expand Down

0 comments on commit 71aa40c

Please sign in to comment.