Project

General

Profile

hts protocol and C#

Added by Frank Galan about 6 years ago

Hello,

I am pretty newbie in this comunity and I am interested in the potential from TVH.
I had found the possibility to write my own wrapper for the HTSP protocol and include it in my automated home software, instead to use kodi with HTSP client as a media entertainment.
For this I was searching what are the implementation and what messages needs to be exchanged by server and wrapper, there is good info in the wiki:
[[https://tvheadend.org/projects/tvheadend/wiki/Htsp]]
Also I had found a quick & dirty implementation in the project from github htsp-sharp (seems discontinued). I tested basic functionality and seems to be quite easy to implement the protocol in a wrapper using TCP messages. Bu I got stucked in a early stage.
there is no too much info (Or I did not catched properly) about how to use the optional extra fields in each commands:
seq
username
digest
seq is understable, but I cannot get logged using username and digest configuration in the TVH Server.
Somebody has an example aboput that? what are the proper sintax for username and digest to be able to connect to server? I always get answer "noaccess"

Thanks in advance.

Regards

Frank


Replies (1)

RE: hts protocol and C# - Added by Frank Galan about 6 years ago

Hello I was doing a deep investigation, and I got some concepts but still not clear for me.
starting from the method "authenticate, I will build my message adding the following information after the succesfull "hello" message:
C# code: (extract)
request = new Message("authenticate");
request.SetIntField("seq", seq++);
request.SetStringField("username", "user");
byte[] challenge = EncodePassword("password");
request.SetBinField("digest", challenge);
client.Send(request);

my EncodePassword method is like this:
public static byte[] EncodePassword(string password) {
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] hash = null;
hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(password));
return hash;
}
And always is returning my noaccess...
Sure that I am doing something wrong, maybe the encode maybe something missed... please has somebody info about that?
I was comparing the python code from existing projects and I suspect something to use together with the "hello" method answer field "challenge", but what I found is to use the size of this byte array. This byte array has 32 bytes, but the encoded sha1 string only can have 20 as far I understand (first time using hash...)
I am little bit lost, can somebody help me?

Regards

Frank Galan

    (1-1/1)