| 1064 | } |
| 1065 | |
| 1066 | void RenderDoc::BecomeRemoteServer(const rdcstr &listenhost, uint16_t port, |
| 1067 | std::function<bool()> killReplay, |
| 1068 | RENDERDOC_PreviewWindowCallback previewWindow) |
| 1069 | { |
| 1070 | Network::Socket *sock = Network::CreateServerSocket(listenhost, port, 1); |
| 1071 | |
| 1072 | if(sock == NULL) |
| 1073 | return; |
| 1074 | |
| 1075 | rdcarray<rdcpair<uint32_t, uint32_t> > listenRanges; |
| 1076 | bool allowExecution = true; |
| 1077 | |
| 1078 | FILE *f = FileIO::fopen(FileIO::GetAppFolderFilename("remoteserver.conf"), FileIO::ReadText); |
| 1079 | |
| 1080 | rdcstr configFile; |
| 1081 | |
| 1082 | if(f) |
| 1083 | { |
| 1084 | FileIO::fseek64(f, 0, SEEK_END); |
| 1085 | configFile.resize((size_t)FileIO::ftell64(f)); |
| 1086 | FileIO::fseek64(f, 0, SEEK_SET); |
| 1087 | |
| 1088 | FileIO::fread(configFile.data(), 1, configFile.size(), f); |
| 1089 | |
| 1090 | FileIO::fclose(f); |
| 1091 | } |
| 1092 | |
| 1093 | rdcarray<rdcstr> lines; |
| 1094 | split(configFile, lines, '\n'); |
| 1095 | |
| 1096 | for(rdcstr &line : lines) |
| 1097 | { |
| 1098 | line.trim(); |
| 1099 | |
| 1100 | if(line == "") |
| 1101 | continue; |
| 1102 | |
| 1103 | // skip comments |
| 1104 | if(line[0] == '#') |
| 1105 | continue; |
| 1106 | |
| 1107 | if(line.substr(0, sizeof("whitelist") - 1) == "whitelist") |
| 1108 | { |
| 1109 | uint32_t ip = 0, mask = 0; |
| 1110 | |
| 1111 | // CIDR notation |
| 1112 | bool found = Network::ParseIPRangeCIDR(line.substr(sizeof("whitelist")), ip, mask); |
| 1113 | |
| 1114 | if(found) |
| 1115 | { |
| 1116 | listenRanges.push_back(make_rdcpair(ip, mask)); |
| 1117 | continue; |
| 1118 | } |
| 1119 | else |
| 1120 | { |
| 1121 | RDCLOG("Couldn't parse IP range from: %s", line.c_str() + sizeof("whitelist")); |
| 1122 | } |
| 1123 |
no test coverage detected