Skip to content

Commit fb025ae

Browse files
authored
Merge pull request #3599 from gabivlj/gv/entropy
Add entropy source to the containers http client
2 parents b59626b + 5ef7b57 commit fb025ae

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/workerd/api/container.c++

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ void Container::signal(jsg::Lock& js, int signo) {
8282
class Container::TcpPortWorkerInterface final: public WorkerInterface {
8383
public:
8484
TcpPortWorkerInterface(capnp::ByteStreamFactory& byteStreamFactory,
85+
kj::EntropySource& entropySource,
8586
const kj::HttpHeaderTable& headerTable,
8687
rpc::Container::Port::Client port)
8788
: byteStreamFactory(byteStreamFactory),
89+
entropySource(entropySource),
8890
headerTable(headerTable),
8991
port(kj::mv(port)) {}
9092

@@ -120,7 +122,7 @@ class Container::TcpPortWorkerInterface final: public WorkerInterface {
120122
connectImpl(*pipe.ends[1]).then([]() -> kj::Promise<void> { return kj::NEVER_DONE; });
121123

122124
// ... and then stack an HttpClient on it ...
123-
auto client = kj::newHttpClient(headerTable, *pipe.ends[0]);
125+
auto client = kj::newHttpClient(headerTable, *pipe.ends[0], {.entropySource = entropySource});
124126

125127
// ... and then adapt that to an HttpService ...
126128
auto service = kj::newHttpService(*client);
@@ -167,6 +169,7 @@ class Container::TcpPortWorkerInterface final: public WorkerInterface {
167169

168170
private:
169171
capnp::ByteStreamFactory& byteStreamFactory;
172+
kj::EntropySource& entropySource;
170173
const kj::HttpHeaderTable& headerTable;
171174
rpc::Container::Port::Client port;
172175

@@ -209,19 +212,22 @@ class Container::TcpPortWorkerInterface final: public WorkerInterface {
209212
class Container::TcpPortOutgoingFactory final: public Fetcher::OutgoingFactory {
210213
public:
211214
TcpPortOutgoingFactory(capnp::ByteStreamFactory& byteStreamFactory,
215+
kj::EntropySource& entropySource,
212216
const kj::HttpHeaderTable& headerTable,
213217
rpc::Container::Port::Client port)
214218
: byteStreamFactory(byteStreamFactory),
219+
entropySource(entropySource),
215220
headerTable(headerTable),
216221
port(kj::mv(port)) {}
217222

218223
kj::Own<WorkerInterface> newSingleUseClient(kj::Maybe<kj::String> cfStr) override {
219224
// At present we have no use for `cfStr`.
220-
return kj::heap<TcpPortWorkerInterface>(byteStreamFactory, headerTable, port);
225+
return kj::heap<TcpPortWorkerInterface>(byteStreamFactory, entropySource, headerTable, port);
221226
}
222227

223228
private:
224229
capnp::ByteStreamFactory& byteStreamFactory;
230+
kj::EntropySource& entropySource;
225231
const kj::HttpHeaderTable& headerTable;
226232
rpc::Container::Port::Client port;
227233
};
@@ -234,8 +240,9 @@ jsg::Ref<Fetcher> Container::getTcpPort(jsg::Lock& js, int port) {
234240

235241
auto& ioctx = IoContext::current();
236242

237-
kj::Own<Fetcher::OutgoingFactory> factory = kj::heap<TcpPortOutgoingFactory>(
238-
ioctx.getByteStreamFactory(), ioctx.getHeaderTable(), req.send().getPort());
243+
kj::Own<Fetcher::OutgoingFactory> factory =
244+
kj::heap<TcpPortOutgoingFactory>(ioctx.getByteStreamFactory(), ioctx.getEntropySource(),
245+
ioctx.getHeaderTable(), req.send().getPort());
239246

240247
return jsg::alloc<Fetcher>(
241248
ioctx.addObject(kj::mv(factory)), Fetcher::RequiresHostAndProtocol::YES, true);

0 commit comments

Comments
 (0)