• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 25066591666

28 Apr 2026 05:01PM UTC coverage: 56.646%. First build
25066591666

Pull #2106

github

web-flow
Merge b71b13f22 into a8e505936
Pull Request #2106: Vs security fix

23 of 60 new or added lines in 4 files covered. (38.33%)

12858 of 22699 relevant lines covered (56.65%)

299321.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.5
/trick_source/sim_services/VariableServer/VariableServer.cpp
1

2
#include <netdb.h>
3
#include <iostream>
4
#include "trick/VariableServer.hh"
5
#include "trick/tc_proto.h"
6

7
Trick::VariableServer * the_vs ;
8

9
Trick::VariableServer::VariableServer() :
210✔
10
 enabled(false) ,
11
 info_msg(false),
12
 log(false),
13
 allow_connections(false),
14
 bypass_ip_check(false)
210✔
15
{
16
    the_vs = this ;
210✔
17
    pthread_mutex_init(&map_mutex, NULL);
210✔
18

19
    ip_whitelist.insert("127.0.0.1");
210✔
20
}
210✔
21

22
Trick::VariableServer::~VariableServer() {
210✔
23
    the_vs = NULL;
210✔
24
}
210✔
25

26
void Trick::VariableServer::shutdownConnections() {
187✔
27
    listen_thread.shutdownConnections();
187✔
28
}
187✔
29

30
std::ostream& Trick::operator<< (std::ostream& s, Trick::VariableServer& vs) {
1✔
31
    std::map < pthread_t , VariableServerSessionThread * >::iterator it ;
1✔
32

33
    s << "{\"variable_server_connections\":[\n";
1✔
34
    int count = 0;
1✔
35
    int n_connections = (int)vs.var_server_threads.size();
1✔
36
    for ( it = vs.var_server_threads.begin() ; it != vs.var_server_threads.end() ; ++it ) {
1✔
37
        s << "{\n";
×
38
        s << *(*it).second;
×
39
        s << "}";
×
40
        if ((n_connections-count)>1) {
×
41
            s << "," ;
×
42
        }
43
        s << "\n";
×
44
        count ++;
×
45
    }
46
    s << "]}" << std::endl;
1✔
47
    return s;
1✔
48
}
49

50
bool Trick::VariableServer::get_enabled() {
2✔
51
    return enabled ;
2✔
52
}
53

54
void Trick::VariableServer::set_enabled(bool on_off) {
31✔
55
    enabled = on_off ;
31✔
56
}
31✔
57

58
bool Trick::VariableServer::get_info_msg() {
10✔
59
    return info_msg ;
10✔
60
}
61

62
void Trick::VariableServer::set_var_server_info_msg_on() {
1✔
63
    info_msg = true;
1✔
64
    for ( auto& session_it : var_server_sessions ) {
1✔
65
        session_it.second->set_info_message(info_msg);
×
66
    }
67
}
1✔
68

69
void Trick::VariableServer::set_var_server_info_msg_off() {
1✔
70
    info_msg = false;
1✔
71
    for ( auto& session_it : var_server_sessions ) {
1✔
72
        session_it.second->set_info_message(info_msg);
×
73
    }
74
}
1✔
75

76
bool Trick::VariableServer::get_log() {
9✔
77
    return log ;
9✔
78
}
79

80
bool Trick::VariableServer::get_session_log() {
9✔
81
    return session_log ;
9✔
82
}
83

84
void Trick::VariableServer::set_var_server_log_on() {
1✔
85
    log = true;
1✔
86
    // turn log on for all current vs clients
87
    for ( auto& session_it : var_server_sessions ) {
2✔
88
        session_it.second->set_log(true);
1✔
89
    }
90
}
1✔
91

92
void Trick::VariableServer::set_var_server_log_off() {
1✔
93
    log = false;
1✔
94
    // turn log off for all current vs clients
95
    for ( auto& session_it : var_server_sessions ) {
2✔
96
        session_it.second->set_log(false);
1✔
97
    }
98
}
1✔
99

100
void Trick::VariableServer::set_var_server_session_log_on() {
1✔
101
    session_log = true;
1✔
102
    // turn log on for all current vs clients
103
    for ( auto& session_it : var_server_sessions ) {
2✔
104
        session_it.second->set_session_log(true);
1✔
105
    }
106
}
1✔
107

108
void Trick::VariableServer::set_var_server_session_log_off() {
1✔
109
    session_log = false;
1✔
110
    // turn log off for all current vs clients
111
    for ( auto& session_it : var_server_sessions ) {
2✔
112
        session_it.second->set_session_log(false);
1✔
113
    }
114
}
1✔
115

116
const char * Trick::VariableServer::get_hostname() {
×
117
    return listen_thread.get_hostname();
×
118
}
119

120
Trick::VariableServerListenThread & Trick::VariableServer::get_listen_thread() {
190✔
121
    return listen_thread ;
190✔
122
}
123

124
void Trick::VariableServer::add_vst(pthread_t in_thread_id, VariableServerSessionThread * in_vst) {
8✔
125
    pthread_mutex_lock(&map_mutex) ;
8✔
126
    var_server_threads[in_thread_id] = in_vst ;
8✔
127
    pthread_mutex_unlock(&map_mutex) ;
8✔
128
}
8✔
129

130
void Trick::VariableServer::add_session(pthread_t in_thread_id, VariableServerSession * in_session) {
12✔
131
    pthread_mutex_lock(&map_mutex) ;
12✔
132
    var_server_sessions[in_thread_id] = in_session ;
12✔
133
    pthread_mutex_unlock(&map_mutex) ;
12✔
134
}
12✔
135

136
Trick::VariableServerSessionThread * Trick::VariableServer::get_vst(pthread_t thread_id) {
5✔
137
    std::map < pthread_t , Trick::VariableServerSessionThread * >::iterator it ;
5✔
138
    Trick::VariableServerSessionThread * ret = NULL ;
5✔
139
    pthread_mutex_lock(&map_mutex) ;
5✔
140
    it = var_server_threads.find(thread_id) ;
5✔
141
    if ( it != var_server_threads.end() ) {
5✔
142
        ret = (*it).second ;
5✔
143
    }
144
    pthread_mutex_unlock(&map_mutex) ;
5✔
145
    return ret ;
5✔
146
}
147

148
Trick::VariableServerSession * Trick::VariableServer::get_session(pthread_t thread_id) {
1,069✔
149
    Trick::VariableServerSession * ret = NULL ;
1,069✔
150
    pthread_mutex_lock(&map_mutex) ;
1,069✔
151
    auto it = var_server_sessions.find(thread_id) ;
1,069✔
152
    if ( it != var_server_sessions.end() ) {
1,069✔
153
        ret = (*it).second ;
37✔
154
    }
155
    pthread_mutex_unlock(&map_mutex) ;
1,069✔
156
    return ret ;
1,069✔
157
}
158

159
void Trick::VariableServer::delete_vst(pthread_t thread_id) {
8✔
160
    pthread_mutex_lock(&map_mutex) ;
8✔
161
    var_server_threads.erase(thread_id) ;
8✔
162
    pthread_mutex_unlock(&map_mutex) ;
8✔
163
}
8✔
164

165
void Trick::VariableServer::delete_session(pthread_t thread_id) {
7✔
166
    pthread_mutex_lock(&map_mutex) ;
7✔
167
    var_server_sessions.erase(thread_id) ;
7✔
168
    pthread_mutex_unlock(&map_mutex) ;
7✔
169
}
7✔
170

171
void Trick::VariableServer::set_copy_data_job( Trick::JobData * in_job ) {
187✔
172
    copy_data_job = in_job ;
187✔
173
}
187✔
174

175
void Trick::VariableServer::set_copy_and_write_freeze_job( Trick::JobData * in_job ) {
187✔
176
    copy_and_write_freeze_job = in_job ;
187✔
177
}
187✔
178

179
bool Trick::VariableServer::set_allow_connections(const bool& b) {
217✔
180
    return allow_connections = b ;
217✔
181
}
182

183
bool Trick::VariableServer::get_allow_connections() {
8✔
184
    return allow_connections ;
8✔
185
}
186

187
bool Trick::VariableServer::set_bypass_ip_check(const bool& b) {
30✔
188
    return bypass_ip_check = b ;
30✔
189
}
190

191
bool Trick::VariableServer::get_bypass_ip_check() {
8✔
192
    return bypass_ip_check ;
8✔
193
}
194

NEW
195
const std::set<std::string>& Trick::VariableServer::get_ip_whitelist() {
×
NEW
196
    return ip_whitelist ;
×
197
}
198

NEW
199
void Trick::VariableServer::add_ip(const std::string& ip) {
×
NEW
200
    ip_whitelist.insert(ip) ;
×
NEW
201
}
×
202

NEW
203
void Trick::VariableServer::remove_ip(const std::string& ip) {
×
NEW
204
    ip_whitelist.erase(ip) ;
×
NEW
205
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc