Skip to content

Instantly share code, notes, and snippets.

View ian-p-cooke's full-sized avatar

Ian P. Cooke ian-p-cooke

View GitHub Profile
BEFORE:
PS C:\Users\ipc\tmp\tonic> D:\apps\ghz.exe --insecure --proto .\examples\proto\helloworld\helloworld.proto --call helloworld.Greeter.SayHello -d '{\"name\":\"Joe\"}' -n 100000 --connections=1 localhost:50051
Summary:
Count: 100000
Total: 3.89 s
Slowest: 13.00 ms
Fastest: 0 ns
Average: 1.87 ms
Requests/sec: 25674.03
// So this code looks wrong to me. What the correct way to "switch" on ethertype to get the next layer?
let packet = // some bytes from a PCAP file
let ether = EthernetPacket::new(&packet).expect("could not parse Ethernet frame");
// I don't know if the next line is valid; what if there's no Vlan layer and it doesn't parse ether.payload()?
let vlan = VlanPacket::new(ether.payload()).expect("could not parse Vlan frame");
let payload = if ether.get_ethertype() == ethernet::EtherTypes::Vlan {
vlan.payload()
} else {
ether.payload()
/// The request message containing the user's name.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HelloRequest {
#[prost(string, tag="1")]
pub name: std::string::String,
}
/// The response message containing the greetings
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HelloReply {
#[prost(string, tag="1")]
#![deny(warnings, rust_2018_idioms)]
use futures::Future;
use hyper::client::connect::{Destination, HttpConnector};
use tower_grpc::Request;
use tower_hyper::{client, util};
use tower_util::MakeService;
use std::error::Error;
struct GracefulTlsStream {
inner: Arc<Mutex<TlsStream<TcpStream, ClientSession>>>,
}
impl Write for GracefulTlsStream {
fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> {
let mut guard = self.inner.lock().unwrap();
guard.write(buf)
}
extern crate sxd_document;
extern crate sxd_xpath;
use std::error::Error;
use sxd_document::parser;
use sxd_xpath::evaluate_xpath;
use sxd_xpath::Value;
use sxd_document::dom::Document;
pub struct XmlFixDictionary<'a> {
@ian-p-cooke
ian-p-cooke / slog_envlogger_actix_web_test.rs
Last active September 6, 2018 11:40
enabling crate level logging not working for actix-web
extern crate actix_web;
extern crate slog_envlogger;
use actix_web::actix;
use actix_web::fs::NamedFile;
use actix_web::middleware;
use actix_web::HttpRequest;
use actix_web::Result;
use actix_web::{server, App};
#[derive(Message)]
struct Batch {
key: String,
messages: Vec<String>
}
struct RedisListTailer {
redis: Addr<Redis>,
key: String,
current_index: isize,
@ian-p-cooke
ian-p-cooke / rustc.log
Created August 5, 2018 15:44
rustc loading codegen error
c:\msys64\home\ipc\rust>rustup toolchain link latest-stage2 build\x86_64-pc-windows-gnu\stage2
c:\msys64\home\ipc\rust>rustup default latest-stage2
info: default toolchain set to 'latest-stage2'
c:\msys64\home\ipc\rust>rustup which rustc
C:\Users\ipc\.rustup\toolchains\latest-stage2\bin\rustc.exe
c:\msys64\home\ipc\rust>rustc -vV
rustc 1.29.0-dev
@ian-p-cooke
ian-p-cooke / add_wsl_exclusions.ps1
Last active June 30, 2024 05:27
powershell script to add WSL exclusions
$win_user = "ipc"
$linux_user = "ipc"
$package = "CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc"
$base_path = "C:\Users\" + $win_user + "\AppData\Local\Packages\" + $package + "\LocalState\rootfs"
$dirs = @("\bin", "\sbin", "\usr\bin", "\usr\sbin", "\home\" + $linux_user + "\.cargo\bin")
$dirs | ForEach { Add-MpPreference -ExclusionProcess ($base_path + $_ + "\*") }
Add-MpPreference -ExclusionPath $base_path