Adding allowed connection
This commit is contained in:
parent
fcef6ba854
commit
0514689dc3
|
@ -3555,7 +3555,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-account-decoder"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"base64 0.21.4",
|
||||
|
@ -3578,7 +3578,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-address-lookup-table-program"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bytemuck",
|
||||
|
@ -3598,7 +3598,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-config-program"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"chrono",
|
||||
|
@ -3611,7 +3611,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-frozen-abi"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"blake3",
|
||||
|
@ -3673,7 +3673,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-frozen-abi-macro"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
|
@ -3696,7 +3696,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-geyser-plugin-interface"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"log",
|
||||
"solana-sdk 1.16.15",
|
||||
|
@ -3707,7 +3707,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-logger"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
|
@ -3728,7 +3728,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-measure"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"log",
|
||||
"solana-sdk 1.16.15",
|
||||
|
@ -3737,7 +3737,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-metrics"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"gethostname",
|
||||
|
@ -3750,7 +3750,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-perf"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"bincode",
|
||||
|
@ -3776,7 +3776,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-program"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"ark-bn254",
|
||||
"ark-ec",
|
||||
|
@ -3884,7 +3884,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-program-runtime"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"base64 0.21.4",
|
||||
"bincode",
|
||||
|
@ -3911,7 +3911,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-rayon-threadlimit"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"num_cpus",
|
||||
|
@ -3920,7 +3920,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-sdk"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"base64 0.21.4",
|
||||
|
@ -4026,7 +4026,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-sdk-macro"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"proc-macro2 1.0.69",
|
||||
|
@ -4051,7 +4051,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-streamer"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"bytes",
|
||||
|
@ -4083,7 +4083,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-transaction-status"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"base64 0.21.4",
|
||||
|
@ -4108,7 +4108,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "solana-vote-program"
|
||||
version = "1.16.15"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_v1.16.15#53907baf5868d4537dfdfca4804f07141e7a7406"
|
||||
source = "git+https://github.com/blockworks-foundation/solana.git?branch=geyser_send_transaction_result_plugin#4641300ad4ecb89340f1c7954be04a74dd2575f2"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"log",
|
||||
|
|
|
@ -7,9 +7,9 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
tokio = { version = "1.21.2", features = ["rt-multi-thread", "macros", "time", "fs"] }
|
||||
solana-sdk = { git = "https://github.com/blockworks-foundation/solana.git", branch = "geyser_send_transaction_result_v1.16.15" }
|
||||
solana-geyser-plugin-interface = { git = "https://github.com/blockworks-foundation/solana.git", branch = "geyser_send_transaction_result_v1.16.15" }
|
||||
solana-streamer = { git = "https://github.com/blockworks-foundation/solana.git", branch = "geyser_send_transaction_result_v1.16.15" }
|
||||
solana-sdk = { git = "https://github.com/blockworks-foundation/solana.git", branch = "geyser_send_transaction_result_plugin" }
|
||||
solana-geyser-plugin-interface = { git = "https://github.com/blockworks-foundation/solana.git", branch = "geyser_send_transaction_result_plugin" }
|
||||
solana-streamer = { git = "https://github.com/blockworks-foundation/solana.git", branch = "geyser_send_transaction_result_plugin" }
|
||||
itertools = "0.10.5"
|
||||
serde = { version = "1.0.160", features = ["derive"] }
|
||||
serde_json = "1.0.96"
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use std::{net::{IpAddr, Ipv4Addr, UdpSocket}, sync::Arc};
|
||||
use std::{net::{IpAddr, Ipv4Addr, UdpSocket}, sync::Arc, str::FromStr};
|
||||
|
||||
use pem::Pem;
|
||||
use quinn::{ServerConfig, IdleTimeout, Endpoint, TokioRuntime, EndpointConfig};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use solana_geyser_plugin_interface::geyser_plugin_interface::{GeyserPlugin, Result as PluginResult, GeyserPluginError};
|
||||
use solana_sdk::{signature::{Signature, Keypair}, transaction::TransactionError, slot_history::Slot, quic::QUIC_MAX_TIMEOUT, packet::PACKET_DATA_SIZE};
|
||||
use solana_streamer::{tls_certificates::new_self_signed_tls_certificate, quic::QuicServerError};
|
||||
use tokio::{runtime::Runtime, task::JoinHandle, sync::mpsc::{UnboundedSender, UnboundedReceiver}};
|
||||
use solana_sdk::{signature::{Signature, Keypair}, transaction::{TransactionError, SanitizedTransaction}, slot_history::Slot, quic::QUIC_MAX_TIMEOUT, packet::PACKET_DATA_SIZE, pubkey::Pubkey};
|
||||
use solana_streamer::{tls_certificates::{new_self_signed_tls_certificate, get_pubkey_from_tls_certificate}, quic::QuicServerError};
|
||||
use tokio::{runtime::Runtime, task::JoinHandle, sync::mpsc::UnboundedSender};
|
||||
|
||||
use crate::skip_client_verification::SkipClientVerification;
|
||||
|
||||
|
@ -46,12 +46,14 @@ impl GeyserPlugin for Plugin {
|
|||
#[allow(unused_variables)]
|
||||
fn notify_banking_stage_transaction_results(
|
||||
&self,
|
||||
transaction: Signature,
|
||||
transaction: &SanitizedTransaction,
|
||||
error: Option<TransactionError>,
|
||||
slot: Slot,
|
||||
) -> PluginResult<()> {
|
||||
if let Some(inner) = self.inner {
|
||||
inner.sender.send(TransactionResults { signature: transaction, error, slot });
|
||||
if let Some(inner) = &self.inner {
|
||||
if let Err(e) = inner.sender.send(TransactionResults { signature: transaction.signature().clone(), error, slot }) {
|
||||
log::error!("error sending on the channel {}", e);
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
Ok(())
|
||||
|
@ -68,6 +70,8 @@ impl GeyserPlugin for Plugin {
|
|||
.map_err(|error| GeyserPluginError::Custom(Box::new(error)))?;
|
||||
let (sender, reciever) = tokio::sync::mpsc::unbounded_channel::<TransactionResults>();
|
||||
|
||||
let allowed_connection = Pubkey::from_str("G8pLuvzarejjLuuPNVNR1gk9xiFKmAcs9J5LL3GZGM6F").unwrap();
|
||||
|
||||
let handle = tokio::spawn(async move {
|
||||
let mut reciever = reciever;
|
||||
loop {
|
||||
|
@ -81,6 +85,15 @@ impl GeyserPlugin for Plugin {
|
|||
continue;
|
||||
}
|
||||
};
|
||||
let connection_identity = get_remote_pubkey(&connection);
|
||||
if let Some(connection_identity) = connection_identity {
|
||||
if !allowed_connection.eq(&connection_identity) {
|
||||
// not an authorized connection
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
let (mut send_stream, _) = match connection.accept_bi().await {
|
||||
Ok(res) => res,
|
||||
Err(e) => {
|
||||
|
@ -92,7 +105,9 @@ impl GeyserPlugin for Plugin {
|
|||
while let Some(msg) = reciever.recv().await {
|
||||
let bytes = bincode::serialize(&msg).unwrap_or(vec![]);
|
||||
if !bytes.is_empty() {
|
||||
let _ = send_stream.write_all(&bytes).await;
|
||||
if let Err(e) = send_stream.write_all(&bytes).await {
|
||||
log::error!("error writing on stream channel {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,4 +159,15 @@ pub(crate) fn configure_server(
|
|||
config.datagram_receive_buffer_size(None);
|
||||
|
||||
Ok((server_config, cert_chain_pem))
|
||||
}
|
||||
|
||||
pub fn get_remote_pubkey(connection: &quinn::Connection) -> Option<Pubkey> {
|
||||
// Use the client cert only if it is self signed and the chain length is 1.
|
||||
connection
|
||||
.peer_identity()?
|
||||
.downcast::<Vec<rustls::Certificate>>()
|
||||
.ok()
|
||||
.filter(|certs| certs.len() == 1)?
|
||||
.first()
|
||||
.and_then(get_pubkey_from_tls_certificate)
|
||||
}
|
Loading…
Reference in New Issue