mirror of https://github.com/aria2/aria2
Merge branch 'dscp-support' of https://github.com/iavael/aria2 into iavael-dscp-support
Conflicts: src/prefs.cc src/prefs.h src/usage_text.hpull/195/head
commit
1438933c97
|
@ -185,6 +185,7 @@ Context::Context(bool standalone,
|
||||||
// when none of network interface has IPv4 address.
|
// when none of network interface has IPv4 address.
|
||||||
setDefaultAIFlags(0);
|
setDefaultAIFlags(0);
|
||||||
}
|
}
|
||||||
|
SocketCore::setIpDscp(op->getAsInt(PREF_DSCP));
|
||||||
net::checkAddrconfig();
|
net::checkAddrconfig();
|
||||||
// Bind interface
|
// Bind interface
|
||||||
if(!op->get(PREF_INTERFACE).empty()) {
|
if(!op->get(PREF_INTERFACE).empty()) {
|
||||||
|
|
|
@ -739,6 +739,15 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||||
op->addTag(TAG_ADVANCED);
|
op->addTag(TAG_ADVANCED);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
OptionHandler* op(new NumberOptionHandler
|
||||||
|
(PREF_DSCP,
|
||||||
|
TEXT_DSCP,
|
||||||
|
"0",
|
||||||
|
0));
|
||||||
|
op->addTag(TAG_ADVANCED);
|
||||||
|
handlers.push_back(op);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
OptionHandler* op(new BooleanOptionHandler
|
OptionHandler* op(new BooleanOptionHandler
|
||||||
(PREF_SELECT_LEAST_USED_HOST,
|
(PREF_SELECT_LEAST_USED_HOST,
|
||||||
|
|
|
@ -83,6 +83,7 @@ bool PeerInitiateConnectionCommand::executeInternal() {
|
||||||
createSocket();
|
createSocket();
|
||||||
getSocket()->establishConnection(getPeer()->getIPAddress(),
|
getSocket()->establishConnection(getPeer()->getIPAddress(),
|
||||||
getPeer()->getPort(), false);
|
getPeer()->getPort(), false);
|
||||||
|
getSocket()->applyIpDscp();
|
||||||
if(mseHandshakeEnabled_) {
|
if(mseHandshakeEnabled_) {
|
||||||
auto c = make_unique<InitiatorMSEHandshakeCommand>
|
auto c = make_unique<InitiatorMSEHandshakeCommand>
|
||||||
(getCuid(), requestGroup_, getPeer(),
|
(getCuid(), requestGroup_, getPeer(),
|
||||||
|
|
|
@ -110,6 +110,7 @@ bool PeerListenCommand::execute() {
|
||||||
std::shared_ptr<SocketCore> peerSocket;
|
std::shared_ptr<SocketCore> peerSocket;
|
||||||
try {
|
try {
|
||||||
peerSocket = socket_->acceptConnection();
|
peerSocket = socket_->acceptConnection();
|
||||||
|
peerSocket->applyIpDscp();
|
||||||
std::pair<std::string, uint16_t> peerInfo;
|
std::pair<std::string, uint16_t> peerInfo;
|
||||||
peerSocket->getPeerInfo(peerInfo);
|
peerSocket->getPeerInfo(peerInfo);
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ enum TlsState {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int SocketCore::protocolFamily_ = AF_UNSPEC;
|
int SocketCore::protocolFamily_ = AF_UNSPEC;
|
||||||
|
int SocketCore::ipDscp_ = 0;
|
||||||
|
|
||||||
std::vector<std::pair<sockaddr_union, socklen_t> >
|
std::vector<std::pair<sockaddr_union, socklen_t> >
|
||||||
SocketCore::bindAddrs_;
|
SocketCore::bindAddrs_;
|
||||||
|
@ -532,6 +533,11 @@ void SocketCore::setTcpNodelay(bool f)
|
||||||
setSockOpt(IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
|
setSockOpt(IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SocketCore::applyIpDscp()
|
||||||
|
{
|
||||||
|
setSockOpt(IPPROTO_IP, IP_TOS, &ipDscp_, sizeof(ipDscp_));
|
||||||
|
}
|
||||||
|
|
||||||
void SocketCore::setNonBlockingMode()
|
void SocketCore::setNonBlockingMode()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|
|
@ -66,6 +66,7 @@ private:
|
||||||
sock_t sockfd_;
|
sock_t sockfd_;
|
||||||
|
|
||||||
static int protocolFamily_;
|
static int protocolFamily_;
|
||||||
|
static int ipDscp_;
|
||||||
|
|
||||||
static std::vector<std::pair<sockaddr_union, socklen_t> > bindAddrs_;
|
static std::vector<std::pair<sockaddr_union, socklen_t> > bindAddrs_;
|
||||||
|
|
||||||
|
@ -120,6 +121,14 @@ public:
|
||||||
// Enables TCP_NODELAY socket option if f == true.
|
// Enables TCP_NODELAY socket option if f == true.
|
||||||
void setTcpNodelay(bool f);
|
void setTcpNodelay(bool f);
|
||||||
|
|
||||||
|
// Set DSCP byte
|
||||||
|
void applyIpDscp();
|
||||||
|
static void setIpDscp(int ipDscp)
|
||||||
|
{
|
||||||
|
// Here we prepare DSCP value for IPTOS option, which sets whole DS field
|
||||||
|
ipDscp_ = ipDscp << 2;
|
||||||
|
}
|
||||||
|
|
||||||
void create(int family, int protocol = 0);
|
void create(int family, int protocol = 0);
|
||||||
|
|
||||||
void bindWithFamily(uint16_t port, int family, int flags = AI_PASSIVE);
|
void bindWithFamily(uint16_t port, int family, int flags = AI_PASSIVE);
|
||||||
|
|
|
@ -361,6 +361,8 @@ PrefPtr PREF_SAVE_SESSION_INTERVAL = makePref("save-session-interval");
|
||||||
PrefPtr PREF_ENABLE_COLOR = makePref("enable-color");
|
PrefPtr PREF_ENABLE_COLOR = makePref("enable-color");
|
||||||
// value: string
|
// value: string
|
||||||
PrefPtr PREF_RPC_SECRET = makePref("rpc-secret");
|
PrefPtr PREF_RPC_SECRET = makePref("rpc-secret");
|
||||||
|
// values: 1*digit
|
||||||
|
PrefPtr PREF_DSCP = makePref("dscp");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FTP related preferences
|
* FTP related preferences
|
||||||
|
|
|
@ -298,6 +298,8 @@ extern PrefPtr PREF_SAVE_SESSION_INTERVAL;
|
||||||
extern PrefPtr PREF_ENABLE_COLOR;
|
extern PrefPtr PREF_ENABLE_COLOR;
|
||||||
// value: string
|
// value: string
|
||||||
extern PrefPtr PREF_RPC_SECRET;
|
extern PrefPtr PREF_RPC_SECRET;
|
||||||
|
// values: 1*digit
|
||||||
|
extern PrefPtr PREF_DSCP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FTP related preferences
|
* FTP related preferences
|
||||||
|
|
|
@ -966,3 +966,13 @@
|
||||||
_(" --enable-color[=true|false] Enable color output for a terminal.")
|
_(" --enable-color[=true|false] Enable color output for a terminal.")
|
||||||
#define TEXT_RPC_SECRET \
|
#define TEXT_RPC_SECRET \
|
||||||
_(" --rpc-secret=TOKEN Set RPC secret authorization token.")
|
_(" --rpc-secret=TOKEN Set RPC secret authorization token.")
|
||||||
|
#define TEXT_DSCP \
|
||||||
|
_(" --dscp=DSCP Set DSCP value in outgoing IP packets of\n" \
|
||||||
|
" BitTorrent traffic for QoS. This parameter sets\n" \
|
||||||
|
" only DSCP bits in TOS field of IP packets,\n" \
|
||||||
|
" not the whole field. If you take values\n" \
|
||||||
|
" from /usr/include/netinet/ip.h divide them by 4\n" \
|
||||||
|
" (otherwise values would be incorrect, e.g. your CS1\n" \
|
||||||
|
" class would turn into CS4). If you are take commonly\n" \
|
||||||
|
" used values from RFC, network vendors' documentation,\n" \
|
||||||
|
" Wikipedia or any other source, use them as they are.")
|
||||||
|
|
Loading…
Reference in New Issue