Skip to content

Commit a81da09

Browse files
committed
add listen_addr
1 parent 8abd3de commit a81da09

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

tcp_server.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ int listen_tcp(
169169
hints.ai_socktype = SOCK_STREAM;
170170
hints.ai_flags = AI_PASSIVE;
171171

172-
// This should only ever listen on a loopback address. Access from outside
173-
// should be proxied via nginx or similar software
174-
status = getaddrinfo("127.0.0.1", params.listen_port.c_str(), &hints, &servinfo);
172+
status = getaddrinfo(params.listen_host.c_str(), params.listen_port.c_str(), &hints, &servinfo);
175173
if (status) {
176174
die("getaddrinfo error: %s", gai_strerror(status));
177175
}

utils.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
8181
#ifndef _WIN32
8282
} else if (arg == "-l" || arg == "--listen") {
8383
params.listen_port = argv[++i];
84+
} else if (arg == "--host") {
85+
params.listen_host = argv[++i];
8486
#endif
8587
} else if (arg == "-h" || arg == "--help") {
8688
gpt_print_usage(argc, argv, params);
@@ -132,6 +134,8 @@ void gpt_print_usage(int /*argc*/, char ** argv, const gpt_params & params) {
132134
#ifndef _WIN32
133135
fprintf(stderr, " -l PORT, --listen PORT\n");
134136
fprintf(stderr, " Run in TCP mode, listening on PORT\n");
137+
fprintf(stderr, " --host ADDR\n");
138+
fprintf(stderr, " When using `--listen`, this specifies the bind addr\n");
135139
#endif
136140
fprintf(stderr, "\n");
137141
}

utils.h

+2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ struct gpt_params {
4141
bool instruct = false; // instruction mode (used for Alpaca models)
4242
bool ignore_eos = false; // do not stop generating after eos
4343
bool perplexity = false; // compute perplexity over the prompt
44+
bool protocol_mode = false; // use an IRC-like protocol with message prefixes and one message per line
4445

4546
#ifndef _WIN32
4647
std::string listen_port = ""; // TCP port for when running in server mode
48+
std::string listen_host = ""; // TCP bind addr when running in server mode
4749
#endif
4850
};
4951

0 commit comments

Comments
 (0)