Skip to content

Commit

Permalink
Merge branch 'release/ios/2024-t1.1' into ft/master/merge2404
Browse files Browse the repository at this point in the history
  • Loading branch information
outman-zhou committed Apr 11, 2024
2 parents 3f42569 + 687e87e commit 88488c7
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 14 deletions.
49 changes: 38 additions & 11 deletions mars/comm/comm_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
// Created by garry on 2017/2/17.
//

#ifndef comm_data_h
#define comm_data_h

#include <stdint.h>
#ifndef mars_comm_data_h
#define mars_comm_data_h

#include <cstdint>
#include <string>

namespace mars {
namespace comm {

// proxy
enum ProxyType {
kProxyNone = 0,
kProxyHttpTunel,
Expand Down Expand Up @@ -75,22 +75,49 @@ class ProxyInfo {
std::string password;
};

//
enum class BizType{CGI = 0, CDN, COUNT};
enum class ProtoType{TCP = 0, QUIC, COUNT};
// connect records
enum class BizType { CGI = 0, CDN, COUNT };
enum class ProtoType { TCP = 0, QUIC, COUNT };

struct ConnRecord{
struct ConnRecord {
BizType biz = BizType::CGI;
ProtoType proto = ProtoType::TCP;
bool succeed = false; //.是否连接成功.
bool succeed = false; //.是否连接成功.
uint64_t begin_timestamp_ms = 0;
unsigned cost_ms = 0;
int nettype = 0; // see NEW_NETTYPE_UNKNOW
};
inline bool operator<(const ConnRecord& lhs, const ConnRecord& rhs){
inline bool operator<(const ConnRecord& lhs, const ConnRecord& rhs) {
return lhs.begin_timestamp_ms < rhs.begin_timestamp_ms;
}

// host resolve
enum EResolveHostPriority {
PRIORITY_NEWDNS_FIRST = 0, // newdns 优先.
PRIORITY_SIMPLEDNS_FIRST, // simpledns优先
};

enum EResolveHostFlag {
FLAG_TRY_NEWDNS = 1,
FLAG_TRY_SIMPLEDNS = 1 << 1,
FLAG_TRY_LOCALDNS = 1 << 2,

FLAGS_NEWDNS_DEFAULT = FLAG_TRY_NEWDNS | FLAG_TRY_LOCALDNS,
FLAGS_SIMPLEDNS_DEFAULT = FLAG_TRY_SIMPLEDNS | FLAG_TRY_LOCALDNS,
FLAGS_ALLINONE = FLAG_TRY_NEWDNS | FLAG_TRY_SIMPLEDNS | FLAG_TRY_LOCALDNS,
FLAGS_ALL_WITHOUT_LOCALDNS = FLAG_TRY_NEWDNS | FLAG_TRY_SIMPLEDNS,
};

enum EHostType {
kHostNone = 0,
kHostFromNewDNS = 1,
kHostFromSysDNS = 2,
kHostFromDebugIP = 3,
kHostFromSimpleDNS = 4,
kHostFromLiteral = 5,
};

} // namespace comm
} // namespace mars

#endif /* comm_data_h */
#endif /* mars_comm_data_h */
27 changes: 26 additions & 1 deletion mars/comm/platform_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void OnPlatformNetworkChange();

int getNetInfo(bool realtime = false);

enum class NetTypeForStatistics {
enum NetTypeForStatistics {
NETTYPE_NON = -1,
NETTYPE_NOT_WIFI = 0,
NETTYPE_WIFI = 1,
Expand All @@ -51,7 +51,32 @@ enum class NetTypeForStatistics {
NETTYPE_UNKNOWN = 6, // ignore, DO NOT reuse
NETTYPE_5G = 7,
};

int getNetTypeForStatistics();
enum {
NEW_NETTYPE_UNKNOW = 0,
NEW_NETTYPE_WIFI = 1,
NEW_NETTYPE_2G = 2,
NEW_NETTYPE_3G = 3,
NEW_NETTYPE_4G = 4,
NEW_NETTYPE_5G = 5,
};
inline int getAppNetType() {
int type = getNetTypeForStatistics();
switch (type) {
case NetTypeForStatistics::NETTYPE_WIFI:
return NEW_NETTYPE_WIFI;
case NetTypeForStatistics::NETTYPE_2G:
return NEW_NETTYPE_2G;
case NetTypeForStatistics::NETTYPE_3G:
return NEW_NETTYPE_3G;
case NetTypeForStatistics::NETTYPE_4G:
return NEW_NETTYPE_4G;
case NetTypeForStatistics::NETTYPE_5G:
return NEW_NETTYPE_5G;
}
return NEW_NETTYPE_UNKNOW;
}

bool getCurRadioAccessNetworkInfo(struct RadioAccessNetworkInfo& _info);

Expand Down
6 changes: 4 additions & 2 deletions mars/stn/src/shortlink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ SOCKET ShortLink::__RunConnect(ConnectProfile& _conn_profile) {
gettimeofday(&now, nullptr);
_conn_profile.end_connect_timestamp_ms = now.tv_sec * 1000 + now.tv_usec / 1000;
_conn_profile.connect_successful_time = ::gettickcount();
_conn_profile.app_nettype = mars::comm::getAppNetType();

delete proxy_addr;
bool contain_v6 = __ContainIPv6(vecaddr);

Expand Down Expand Up @@ -584,8 +586,8 @@ void ShortLink::__RunReadWrite(SOCKET _socket, int& _err_type, int& _err_code, C
memset(dstbuf, 0, dstlen);

int retsize = mars::comm::EncodeBase64((unsigned char*)account_info.c_str(),
(unsigned char*)dstbuf,
(int)account_info.length());
(unsigned char*)dstbuf,
(int)account_info.length());
dstbuf[retsize] = '\0';

char auth_info[1024] = {0};
Expand Down
2 changes: 2 additions & 0 deletions mars/stn/task_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ struct ConnectProfile {
tls_handshake_success = false;
channel_type = 0;
rtt_by_socket = 0;
app_nettype = 0;

begin_connect_timestamp_ms = 0;
end_connect_timestamp_ms = 0;
Expand Down Expand Up @@ -231,6 +232,7 @@ struct ConnectProfile {
int channel_type;
int rtt_by_socket;
std::string netlabel;
int app_nettype;

//
uint64_t begin_connect_timestamp_ms;
Expand Down

0 comments on commit 88488c7

Please sign in to comment.