chromium/net/base/port_util.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/base/port_util.h"

#include <limits>
#include <set>

#include "base/containers/fixed_flat_map.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "url/url_constants.h"

namespace net {

namespace {

// The general list of blocked ports. Will be blocked unless a specific
// protocol overrides it. (Ex: ftp can use port 21)
// When adding a port to the list, consider also adding it to kAllowablePorts,
// below. See <https://fetch.spec.whatwg.org/#port-blocking>.
const int kRestrictedPorts[] =;

base::LazyInstance<std::multiset<int>>::Leaky g_explicitly_allowed_ports =;

// List of ports which are permitted to be reenabled despite being in
// kRestrictedList. When adding an port to this list you should also update the
// enterprise policy to document the fact that the value can be set. Ports
// should only remain in this list for about a year to give time for users to
// migrate off while stopping them from becoming permanent parts of the web
// platform.
constexpr int kAllowablePorts[] =;

int g_scoped_allowable_port =;

}  // namespace

bool IsPortValid(int port) {}

bool IsWellKnownPort(int port) {}

bool IsPortAllowedForScheme(int port, std::string_view url_scheme) {}

size_t GetCountOfExplicitlyAllowedPorts() {}

// Specifies a comma separated list of port numbers that should be accepted
// despite bans. If the string is invalid no allowed ports are stored.
void SetExplicitlyAllowedPorts(base::span<const uint16_t> allowed_ports) {}

ScopedPortException::ScopedPortException(int port) :{}

ScopedPortException::~ScopedPortException() {}

NET_EXPORT bool IsAllowablePort(int port) {}

ScopedAllowablePortForTesting::ScopedAllowablePortForTesting(int port) {}

ScopedAllowablePortForTesting::~ScopedAllowablePortForTesting() {}

}  // namespace net