blob: 57c0b4c7ea7822c0070c6c3fa10307bfee963020 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "platform/network/NetworkUtils.h"
#include "net/base/ip_address.h"
#include "net/base/url_util.h"
#include "wtf/text/StringUTF8Adaptor.h"
#include "wtf/text/WTFString.h"
namespace blink {
namespace NetworkUtils {
bool isReservedIPAddress(const String& host)
{
net::IPAddress address;
StringUTF8Adaptor utf8(host);
if (!net::ParseURLHostnameToAddress(utf8.asStringPiece(), &address))
return false;
return address.IsReserved();
}
bool isLocalHostname(const String& host, bool* isLocal6)
{
StringUTF8Adaptor utf8(host);
return net::IsLocalHostname(utf8.asStringPiece(), isLocal6);
}
} // NetworkUtils
} // namespace blink