@@ -141,8 +141,6 @@ static void remove_from_beginning(std::vector<char>* buffer, size_t count) {
141141 buffer->erase (buffer->begin (), buffer->begin () + count);
142142}
143143
144- // Cleanup
145-
146144static const char CLOSE_FRAME[] = {' \x88 ' , ' \x00 ' };
147145
148146enum ws_decode_result {
@@ -160,15 +158,6 @@ static void generate_accept_string(const std::string& client_key,
160158 node::base64_encode (hash, sizeof (hash), *buffer, sizeof (*buffer));
161159}
162160
163- static bool IsOneOf (const std::string& host,
164- const std::vector<std::string>& hosts) {
165- for (const std::string& candidate : hosts) {
166- if (node::StringEqualNoCase (host.data (), candidate.data ()))
167- return true ;
168- }
169- return false ;
170- }
171-
172161static std::string TrimPort (const std::string& host) {
173162 size_t last_colon_pos = host.rfind (" :" );
174163 if (last_colon_pos == std::string::npos)
@@ -192,16 +181,6 @@ static bool IsIPAddress(const std::string& host) {
192181 return quads == 3 ;
193182}
194183
195- // This is a value coming from the interface, it can only be IPv4 or IPv6
196- // address string.
197- static bool IsIPv4Localhost (const std::string& host) {
198- std::string v6_tunnel_prefix = " ::ffff:" ;
199- if (host.substr (0 , v6_tunnel_prefix.length ()) == v6_tunnel_prefix)
200- return IsIPv4Localhost (host.substr (v6_tunnel_prefix.length ()));
201- std::string localhost_net = " 127." ;
202- return host.substr (0 , localhost_net.length ()) == localhost_net;
203- }
204-
205184// Constants for hybi-10 frame format.
206185
207186typedef int OpCode;
@@ -600,17 +579,9 @@ class HttpHandler : public ProtocolHandler {
600579
601580 bool IsAllowedHost (const std::string& host_with_port) const {
602581 std::string host = TrimPort (host_with_port);
603- if (host.empty ())
604- return false ;
605- if (IsIPAddress (host))
606- return true ;
607- std::string socket_host = GetHost ();
608- if (IsIPv4Localhost (socket_host)) {
609- return IsOneOf (host, { " localhost" });
610- } else if (socket_host == " ::1" ) {
611- return IsOneOf (host, { " localhost" , " localhost6" });
612- }
613- return true ;
582+ return host.empty () || IsIPAddress (host)
583+ || node::StringEqualNoCase (host.data (), " localhost" )
584+ || node::StringEqualNoCase (host.data (), " localhost6" );
614585 }
615586
616587 bool parsing_value_;
0 commit comments