- name: Build all
run: |
export CGO_LDFLAGS='-lntdll -lWs2_32 -lcrypt32 -lSecur32 -luserenv -lNcrypt -lbcrypt'
- make all
+ mingw32-make.exe all
- uses: actions/upload-artifact@v3
with:
name: macos
@mkdir -p build/{lib,bin}
# Builds all rust targets
-build/lib/liball_in_one.a build/bin/{cache,gateway,ratelimit,rest,webhook}: build/{bin,lib}
+build/lib/liball_in_one.a build/bin/{cache,gateway,ratelimit,rest,webhook}{,.exe}: build/{bin,lib}
@echo "Building rust project"
cargo build --release
@cp target/release/liball_in_one.a build/lib
- @cp target/release/{cache,gateway,ratelimit,rest,webhook} build/bin
+ @cp target/release/{cache,gateway,ratelimit,rest,webhook}{,.exe} build/bin || true
# Generated by a rust build script.
internal/pkg/all-in-one/all-in-one.h: build/lib/liball_in_one.a
build/bin/nova: build/lib/liball_in_one.a internal/pkg/all-in-one/all-in-one.h
go build -a -ldflags '-s' -o build/bin/nova cmd/nova/nova.go
-all: build/bin/{cache,gateway,ratelimit,rest,webhook} build/bin/nova
+all: build/bin/{cache,gateway,ratelimit,rest,webhook}{,.exe} build/bin/nova
docker-images:
docker-compose build
time::Duration,
};
use tokio::{sync::oneshot, task::JoinHandle};
-use tracing::debug;
+use tracing::{debug, trace};
use twilight_http_ratelimiting::headers::Present;
use super::{async_queue::AsyncQueue, atomic_instant::AtomicInstant, redis_lock::RedisLock};
this.remaining.fetch_sub(1, Ordering::Relaxed);
let _ = element
.send(())
- .map_err(|_| debug!("response channel was closed."));
+ .map_err(|_| trace!("response channel was closed."));
}
});
}
let request_path = request.uri().path();
let (api_path, trimmed_path) = normalize_path(request_path);
- let mut uri_string = format!("https://discord.com{}{}", api_path, trimmed_path);
+ let mut uri_string = format!("http://127.0.0.1:9999{}{}", api_path, trimmed_path);
if let Some(query) = request.uri().query() {
uri_string.push('?');
uri_string.push_str(query);
));
let https = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
- .https_only()
+ .https_or_http()
.enable_http1()
.build();
#[derive(Clone, Debug)]
pub struct RemoteRatelimiter {
remotes: Arc<RwLock<HashRingWrapper>>,
+ current_remotes: Vec<String>,
+
stop: Arc<tokio::sync::broadcast::Sender<()>>,
config: ReverseProxyConfig,
}
impl RemoteRatelimiter {
async fn get_ratelimiters(&self) -> Result<(), anyhow::Error> {
// get list of dns responses
- let responses = dns_lookup::lookup_host(&self.config.ratelimiter_address)?
+ let responses: Vec<String> = dns_lookup::lookup_host(&self.config.ratelimiter_address)?
.into_iter()
.filter(|address| address.is_ipv4())
- .map(|address| address.to_string());
+ .map(|address| address.to_string())
+ .collect();
let mut write = self.remotes.write().await;
- for ip in responses {
- let a = VNode::new(ip, self.config.ratelimiter_port).await?;
- write.add(a.clone());
+ for ip in &responses {
+ if !self.current_remotes.contains(&ip) {
+ let a = VNode::new(ip.to_owned(), self.config.ratelimiter_port).await?;
+ write.add(a.clone());
+ }
}
Ok(())
remotes: Arc::new(RwLock::new(HashRingWrapper::default())),
stop: Arc::new(rx),
config,
+ current_remotes: vec![]
};
let obj_clone = obj.clone();
}
}
- let sleep = tokio::time::sleep(Duration::from_secs(10));
+ let sleep = tokio::time::sleep(Duration::from_secs(5));
tokio::pin!(sleep);
tokio::select! {
() = &mut sleep => {