2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
23 #include "user_traff.h"
34 //-----------------------------------------------------------------------------
37 #ifdef TRAFF_STAT_WITH_PORTS
38 IPDirPair(uint32_t _ip, int _dir, uint16_t _port) noexcept
44 IPDirPair(uint32_t _ip, int _dir) noexcept
49 //------------------------
50 bool operator<(const IPDirPair& rhs) const noexcept
58 #ifdef TRAFF_STAT_WITH_PORTS
71 //------------------------
72 bool operator==(const IPDirPair& rhs) const noexcept
74 #ifdef TRAFF_STAT_WITH_PORTS
75 return ip == rhs.ip && port == rhs.port && dir == rhs.dir;
77 return ip == rhs.ip && dir == rhs.dir;
80 bool operator!=(const IPDirPair& rhs) const noexcept
82 return !operator==(rhs);
85 IPDirPair(const IPDirPair&) = default;
86 IPDirPair& operator=(const IPDirPair&) = default;
87 IPDirPair(IPDirPair&&) = default;
88 IPDirPair& operator=(IPDirPair&&) = default;
89 //------------------------
92 #ifdef TRAFF_STAT_WITH_PORTS
96 //-----------------------------------------------------------------------------
99 StatNode(uint64_t _up, uint64_t _down, double _cash) noexcept
105 StatNode(const StatNode&) = default;
106 StatNode& operator=(const StatNode&) = default;
107 StatNode(StatNode&&) = default;
108 StatNode& operator=(StatNode&&) = default;
114 //-----------------------------------------------------------------------------
126 UserStat(const UserStat&) = default;
127 UserStat& operator=(const UserStat&) = default;
128 UserStat(UserStat&&) = default;
129 UserStat& operator=(UserStat&&) = default;
132 DirTraff sessionDown;
138 time_t lastCashAddTime;
140 time_t lastActivityTime;
142 //-----------------------------------------------------------------------------
143 using TraffStat = std::map<IPDirPair, StatNode>;
144 //-----------------------------------------------------------------------------
145 using CashInfo = std::pair<double, std::string>;
146 //-----------------------------------------------------------------------------
149 UserStatOpt() = default;
151 UserStatOpt(const UserStat& data) noexcept
154 lastCashAdd(data.lastCashAdd),
155 lastCashAddTime(data.lastCashAddTime),
156 passiveTime(data.passiveTime),
157 lastActivityTime(data.lastActivityTime),
158 sessionUp(data.sessionUp),
159 sessionDown(data.sessionDown),
160 monthUp(data.monthUp),
161 monthDown(data.monthDown)
163 UserStatOpt& operator=(const UserStat& us)
167 lastCashAdd = us.lastCashAdd;
168 lastCashAddTime = us.lastCashAddTime;
169 passiveTime = us.passiveTime;
170 lastActivityTime = us.lastActivityTime;
171 sessionUp = us.sessionUp;
172 sessionDown = us.sessionDown;
173 monthUp = us.monthUp;
174 monthDown = us.monthDown;
178 UserStatOpt(const UserStatOpt&) = default;
179 UserStatOpt& operator=(const UserStatOpt&) = default;
180 UserStatOpt(UserStatOpt&&) = default;
181 UserStatOpt& operator=(UserStatOpt&&) = default;
183 std::optional<double> cash;
184 std::optional<CashInfo> cashAdd;
185 std::optional<CashInfo> cashSet;
186 std::optional<double> freeMb;
187 std::optional<double> lastCashAdd;
188 std::optional<time_t> lastCashAddTime;
189 std::optional<time_t> passiveTime;
190 std::optional<time_t> lastActivityTime;
191 DirTraffOpt sessionUp;
192 DirTraffOpt sessionDown;
194 DirTraffOpt monthDown;
196 //-----------------------------------------------------------------------------