Skip to content

Instantly share code, notes, and snippets.

View haesbaert's full-sized avatar

Christiano Haesbaert haesbaert

View GitHub Profile
let _ =
let sock = Unix.socket Unix.PF_INET Unix.SOCK_DGRAM 0 in
let () = ExtUnixSpecific.setsockopt_bool sock ExtUnixSpecific.IP_RECVIF true in
let () = ExtUnixSpecific.setsockopt_bool sock ExtUnixSpecific.IP_RECVDSTADDR true in
let () = Unix.bind sock (Unix.ADDR_INET (Unix.inet_addr_any, 7373)) in
let buf = Bytes.create 1024 in
let n, saddr, l = ExtUnixSpecific.recvmsg2 sock buf 0 1024 in
let () = match saddr with
| Unix.ADDR_INET (a, p) -> Printf.printf "a = %s p = %d\n" (Unix.string_of_inet_addr a) p
| _ -> ()
let scan_pkt buf =
let open Usane in
let len = Cstruct.len buf in
let partial () =
if len < (1024 * 64) then
None
else
invalid_arg "Buffer is too big"
in
let wrap () =
let decode_mpint buf =
trap_error (fun () ->
let rec strip_zeros buf =
if (Cstruct.get_uint8 buf 0) <> 0 then
buf
else
strip_zeros (Cstruct.shift buf 1)
in
match ((Cstruct.BE.get_uint32 buf 0) |> Int32.to_int) with
| 0 -> (Cstruct.create 0, buf) (* XXX not sure, should we fake 0 *)
(* case 1 *)
let rec expand need kn =
if (Cstruct.len kn) >= need then
kn
else
expand need (hf [k; h; kn])
in
(* case 2 *)
let need = 10 in
(*
* Copyright (c) 2017 Christiano F. Haesbaert <haesbaert@haesbaert.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
module Channel = struct
(* XXX find me a better home *)
type channel_end = {
id : int32;
max_pkt : int32;
win : int32;
}
type t = {
us : channel_end;
type channel_end = {
id : int32;
max_pkt : int32;
win : int32;
}
type t = {
us : channel_end;
feanor:awa-ssh: sh build.sh
+ ocamlfind ocamlc -c -g -bin-annot -safe-string -strict-sequence -package 'cstruct-unix io-page.unix' -package 'ipaddr zarith x509' -package 'nocrypto rresult cstruct cstruct.ppx sexplib ppx_sexp_conv' -I drivers/test -I lib -I drivers -o drivers/test/awa_test_server.cmo drivers/test/awa_test_server.ml
File "drivers/test/awa_test_server.ml", line 72, characters 4-27:
Error: The constructor Awa.Server.Disconnected belongs to the variant type
Awa.Server.event
but a constructor was expected belonging to the variant type
Server.event
Command exited with code 2.
Compilation unsuccessful after building 53 targets (0 cached) in 00:00:11.
pkg.ml: [ERROR] cmd ['ocamlbuild' '-use-ocamlfind' '-j' '4' '-tag' 'debug' '-build-dir'
version = "%%VERSION_NUM%%"
description = "Pure SSH library implmentation in ocaml"
requires = "str cstruct sexplib result nocrypto ipaddr lwt"
archive(byte) = "awa.cma"
plugin(byte) = "awa.cma"
archive(native) = "awa.cmxa"
plugin(native) = "awa.cmxs"
exists_if = "awa.cma"
>>= r ->
match r with
| dsadada
>>= (function
| dda ->
|
See I lose 4 characters !