MCPcopy Index your code
hub / github.com/bedroombuilds/python2rust / main

Function main

1b_sockets/rust/tlsecho/src/bin/server.rs:16–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14}
15
16fn main() {
17 let mut config = rustls::ServerConfig::new(rustls::NoClientAuth::new());
18 let certs = open_cert_file("../../certchain.pem", rustls::internal::pemfile::certs);
19 let key = open_cert_file(
20 "../../private.key",
21 rustls::internal::pemfile::pkcs8_private_keys,
22 )
23 .pop()
24 .unwrap();
25 let listener = TcpListener::bind("127.0.0.1:12321").unwrap();
26 config.set_single_cert(certs, key).unwrap();
27 println!("server is running on 127.0.0.1:12321 ...");
28
29 for socket in listener.incoming() {
30 let socket = socket.unwrap();
31 let config = config.clone();
32 thread::spawn(move || handle_client(socket, Arc::new(config)));
33 }
34}
35
36fn handle_client(mut socket: TcpStream, config: Arc<rustls::ServerConfig>) {
37 let mut sess = rustls::ServerSession::new(&config);

Callers

nothing calls this directly

Calls 2

open_cert_fileFunction · 0.70
handle_clientFunction · 0.70

Tested by

no test coverage detected